# Game keeps crashing

**URL:** <https://forum.makecode.com/t/game-keeps-crashing/34899>\
**Category:** Help\
**Tags:** game\
**Created:** [March 25, 2025, 10:18pm UTC](https://forum.makecode.com/t/game-keeps-crashing/34899 "2025-03-25T22:18:19Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![swirlix](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/swirlix/32/35624_2.png) [@swirlix](https://forum.makecode.com/u/swirlix)\
**Post date:** [March 25, 2025, 10:18pm UTC](https://forum.makecode.com/t/game-keeps-crashing/34899/1 "2025-03-25T22:18:19Z")

</div>

I am making an RPG, but every time the battle ends, the game crashes. Please help, I don’t know how to fix this. here is the link

> **[rpg test](https://arcade.makecode.com/S23001-95364-42697-03251)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

btw arrow keys or wasd to move, and to activate battle just move around and try to go onto a different grass block. (it just looks different)

---

<div class="post-metadata">

**Author:** ![Tasty\_turnip2](https://avatars.discourse-cdn.com/v4/letter/t/e9c0ed/32.png) [@Tasty\_turnip2](https://forum.makecode.com/u/Tasty_turnip2)\
**Post date:** [March 28, 2025, 5:09pm UTC](https://forum.makecode.com/t/game-keeps-crashing/34899/2 "2025-03-28T17:09:21Z")

</div>

Tip: The JavaScript section tells you where the errors are in the code. Then, you can look at what it says has an error and try to find it in the blocks.  
It seems like the error is happening in the “enemyattackcheck” function, but I don’t understand what is happening, so I can’t diagnose exactly where the error is.  
Hope this is helpful.

---

<div class="post-metadata">

**Author:** ![WoofWoof](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/woofwoof/32/32523_2.png) [@WoofWoof](https://forum.makecode.com/u/WoofWoof)\
**Post date:** [March 28, 2025, 5:23pm UTC](https://forum.makecode.com/t/game-keeps-crashing/34899/3 "2025-03-28T17:23:33Z")

</div>

I would recommend playing the game in Debug Mode so that it shows you the actual error instead of just the “sim error…” whatever.

 ![IMG_8168](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/3X/6/e/6e82140444dc9350673cb0bff79673591fa7f05d.jpeg)  
It looks like you call this function even after the game is over, so the status bar tries to update even though it doesn’t exist anymore! This is causing the error.

---

<div class="post-metadata">

**Author:** ![swirlix](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/swirlix/32/35624_2.png) [@swirlix](https://forum.makecode.com/u/swirlix)\
**Post date:** [March 28, 2025, 11:25pm UTC](https://forum.makecode.com/t/game-keeps-crashing/34899/4 "2025-03-28T23:25:03Z")

</div>

Thanks for your help, but It should not do that function in the first place, that was the problem. I already knew about debug mode  
.

---

<div class="post-metadata">

**Author:** ![WoofWoof](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/woofwoof/32/32523_2.png) [@WoofWoof](https://forum.makecode.com/u/WoofWoof)\
**Post date:** [March 29, 2025, 12:44am UTC](https://forum.makecode.com/t/game-keeps-crashing/34899/5 "2025-03-29T00:44:12Z")

</div>

In that case, if you can’t find the cause, you can just add a check using another variable, like a “inBattleMod” variable or smth, idk.
