# Game is crashing and is pointing to a random variable

**URL:** <https://forum.makecode.com/t/game-is-crashing-and-is-pointing-to-a-random-variable/39458>\
**Category:** Help\
**Created:** [September 23, 2025, 5:02pm UTC](https://forum.makecode.com/t/game-is-crashing-and-is-pointing-to-a-random-variable/39458 "2025-09-23T17:02:58Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![odyyseus7](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/odyyseus7/32/21687_2.png) [@odyyseus7](https://forum.makecode.com/u/odyyseus7)\
**Post date:** [September 23, 2025, 5:02pm UTC](https://forum.makecode.com/t/game-is-crashing-and-is-pointing-to-a-random-variable/39458/1 "2025-09-23T17:02:58Z")

</div>

im trying to make my own life system cause I’ve done It before but it crashes when it reaches 0 and I cant figure out why [https://arcade.makecode.com/S54417-06884-67347-37321](https://arcade.makecode.com/S54417-06884-67347-37321)

---

<div class="post-metadata">

**Author:** ![Green\_Lizard](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/green_lizard/32/33280_2.png) [@Green\_Lizard](https://forum.makecode.com/u/Green_Lizard)\
**Post date:** [September 23, 2025, 8:22pm UTC](https://forum.makecode.com/t/game-is-crashing-and-is-pointing-to-a-random-variable/39458/2 "2025-09-23T20:22:26Z")

</div>

![1000000243](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/3X/8/e/8eee237d61f35442146606f88880ca5c67386294.jpeg)

Its saying “cant read properties of undefined reading fields”

This is causing it to crash

---

<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:** [September 23, 2025, 8:24pm UTC](https://forum.makecode.com/t/game-is-crashing-and-is-pointing-to-a-random-variable/39458/3 "2025-09-23T20:24:23Z")

</div>

It seems your Forever block is running right after the Splash block activates, which it simply shouldn’t be doing. You can fix this by putting an ` if <lifeblood =/= 3>...` around it to stop it from running that code after the splash block happens.

@Richard, somehow these Forever blocks are still running after the splash block has pushed the scene, how come?  
If you put a breakpoint on the Splash block, which is at the bottom of the Forever block just right of the On Start, you can die in the game to activate it and then ‘step’ after it. You’ll see that the Forever blocks still run once after the splash block runs.

---

<div class="post-metadata">

**Author:** ![richard](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/richard/32/5417_2.png) [@richard](https://forum.makecode.com/u/richard)\
**Post date:** [September 23, 2025, 8:29pm UTC](https://forum.makecode.com/t/game-is-crashing-and-is-pointing-to-a-random-variable/39458/4 "2025-09-23T20:29:22Z")

</div>

it’s possible for that to happen if you pause inside the forever. for example:

> **[forever-pause-example](https://arcade.makecode.com/60770-26284-23077-71169)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

that’s why when you’re doing something in a forever loop that pauses, it’s best to only pause once as the last block in the loop. if that isn’t possible, then you should have a variable like “splashOpen” that you can check after each pause to see if you should bail out.

---

<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:** [September 23, 2025, 11:17pm UTC](https://forum.makecode.com/t/game-is-crashing-and-is-pointing-to-a-random-variable/39458/5 "2025-09-23T23:17:46Z")

</div>

They aren’t pausing inside the forever block that is running after the splash though. Maybe the “play song in background” blocks are pausing somewhere? But if that were the case you would see the next ‘step’ start after the “play song” block, and the next step starts right at the top of the Forever block, even after running a _different_ Forever block. You can tell the scene has already been pushed because the “location” variable set to to the location of player1 is null after that block is run.

Breakpoint activates after purposely dying:

 ![Screenshot 2025-09-23 at 4.35.00 PM](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/3X/d/f/dff0a9e86a8ed4eac318a750cb3aa2c796ceb9b4.png)

After pressing ‘step’ a forever block that doesn’t cause any errors runs (Splash dialogue still hasn’t appeared, though that may be a Debug Mode issue?):

 ![Screenshot 2025-09-23 at 4.35.27 PM](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/3X/0/b/0b537e3704e3fb655b82f67805cc7c0d9e884d61.png)

Offending code runs, though I’ve fixed the issue with the extra If block, the “location” variable has been set to ‘null’, so the scene has been pushed:

 ![Screenshot 2025-09-23 at 4.36.12 PM](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/3X/c/5/c5b2dd1653a1f72a132829aae3997d2284deb3d2.png)

Splash dialogue appears once the Forever loop completes.

 ![Screenshot 2025-09-23 at 4.36.44 PM](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/3X/7/4/74c0e137b911fec3d0d0a8a6796a67193c54cad3.jpeg)  
Then a few seconds later a random bit of code that was in a “run after” block runs, but that isn’t important, just annoying.

---

<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:** [September 29, 2025, 9:57pm UTC](https://forum.makecode.com/t/game-is-crashing-and-is-pointing-to-a-random-variable/39458/6 "2025-09-29T21:57:31Z")

</div>

I guess I forgot to ping @richard 😅

---

<div class="post-metadata">

**Author:** ![odyyseus7](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/odyyseus7/32/21687_2.png) [@odyyseus7](https://forum.makecode.com/u/odyyseus7)\
**Post date:** [October 1, 2025, 11:09pm UTC](https://forum.makecode.com/t/game-is-crashing-and-is-pointing-to-a-random-variable/39458/7 "2025-10-01T23:09:22Z")

</div>

Thank you so much for the help 🙂
