# Cutscene like code help

**URL:** <https://forum.makecode.com/t/cutscene-like-code-help/6915>\
**Category:** Help\
**Created:** [March 22, 2021, 8:37pm UTC](https://forum.makecode.com/t/cutscene-like-code-help/6915 "2021-03-22T20:37:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![brandodon](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/brandodon/32/3625_2.png) [@brandodon](https://forum.makecode.com/u/brandodon)\
**Post date:** [March 22, 2021, 8:37pm UTC](https://forum.makecode.com/t/cutscene-like-code-help/6915/1 "2021-03-22T20:37:25Z")

</div>

alright, so I’m making a cutscene of text (no extensions just splash dialog and then a function), so I have an onUpdate(function() {} and I said this:

game.onUpdate(function() {  
if (speed \> 20) {  
game.splash(“blah”)  
game.splash(“blah”)  
game.splash(“blah”)  
Hard()  
}

(you can copy and paste that into javascript, and convert it to blocks if needed)

I understand the problem here, it’s running this code every time it updates and the code sees that the speed is over 20. Making the code basically run forever, because it doesn’t update on intervals or stop updating, it always updates. Is there any way to fix this?

JAVASCRIPT HELP!

---

<div class="post-metadata">

**Author:** ![brandodon](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/brandodon/32/3625_2.png) [@brandodon](https://forum.makecode.com/u/brandodon)\
**Post date:** [March 22, 2021, 8:52pm UTC](https://forum.makecode.com/t/cutscene-like-code-help/6915/2 "2021-03-22T20:52:22Z")

</div>

By the way ‘Hard()’ is a function that has a game.onUpdateInterval(0000, function() {} inside of it if that helps. The code inside of this function does not have any interference with any other code in the project.

---

<div class="post-metadata">

**Author:** ![jwunderl](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/jwunderl/32/5308_2.png) [@jwunderl](https://forum.makecode.com/u/jwunderl)\
**Post date:** [March 22, 2021, 9:39pm UTC](https://forum.makecode.com/t/cutscene-like-code-help/6915/3 "2021-03-22T21:39:21Z")

</div>

The easiest way to handle this would be with a boolean flag; you keep track of whether you’ve shown the cutscene before in a variable, and only show it the first time it triggers. For example, something like:

```typescript
let hardModeSceneDisplayed = false;
game.onUpdate(function() {
    if (speed > 20 && !hardModeSceneDisplayed) {
        hardModeSceneDisplayed = true;
        game.splash(“blah”)
        game.splash(“blah”)
        game.splash(“blah”)
        Hard()
    }
});

```

---

<div class="post-metadata">

**Author:** ![brandodon](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/brandodon/32/3625_2.png) [@brandodon](https://forum.makecode.com/u/brandodon)\
**Post date:** [March 22, 2021, 9:43pm UTC](https://forum.makecode.com/t/cutscene-like-code-help/6915/4 "2021-03-22T21:43:26Z")

</div>

Thanks!
