# Null error (how?)

**URL:** <https://forum.makecode.com/t/null-error-how/36140>\
**Category:** Help\
**Created:** [April 25, 2025, 11:58pm UTC](https://forum.makecode.com/t/null-error-how/36140 "2025-04-25T23:58:45Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Harmanuary](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/harmanuary/32/21855_2.png) [@Harmanuary](https://forum.makecode.com/u/Harmanuary)\
**Post date:** [April 25, 2025, 11:58pm UTC](https://forum.makecode.com/t/null-error-how/36140/1 "2025-04-25T23:58:45Z")

</div>

![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/3X/0/b/0ba9eb8831fb211a3054fabdc21b304a16cc1b0f.png)  
So this game allows you to choose how many people can play, at the start it asks you 1, 2, and 3, every time I go to shoot an egg out in single player it will crash on a random shot. I remove the last answer equals 2 and 3 and the crash doesn’t happen but then a core thing for how the egg shooting works is removed. I have the link for the game if you’d like to take a look

> **[Birds of a Feather](https://arcade.makecode.com/S94407-35558-25430-04513)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

---

<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:** [April 26, 2025, 4:01pm UTC](https://forum.makecode.com/t/null-error-how/36140/2 "2025-04-26T16:01:29Z")

</div>

Looks like there might be an error in the story extension! It seems that when you select an option, the menu is still running in the background, so when you press up or down and then click A, the most recent button is no longer option 1, and the game errors because the “player2” sprite doesn’t exist!

What you can do to fix this is make a new variable set to the selected option right after the player selects it. That way, your variable won’t change even if the last selected option variable does change. Then just use that variable instead of the built in one.

Oh and I guess @makecode can y’all look into the story extension? It probably isn’t removing the event handlers properly when the menu closes.

---

<div class="post-metadata">

**Author:** ![redSprite](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/redsprite/32/34262_2.png) [@redSprite](https://forum.makecode.com/u/redSprite)\
**Post date:** [April 26, 2025, 4:03pm UTC](https://forum.makecode.com/t/null-error-how/36140/3 "2025-04-26T16:03:57Z")

</div>

I think its because “Sprite2” hasn’t been given a sprite definition by the time the simulator runs that piece of code.

Try clicking on that warning sign on the malfunctioning block.

---

<div class="post-metadata">

**Author:** ![BlobDev](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/blobdev/32/25519_2.png) [@BlobDev](https://forum.makecode.com/u/BlobDev)\
**Post date:** [April 26, 2025, 5:56pm UTC](https://forum.makecode.com/t/null-error-how/36140/5 "2025-04-26T17:56:49Z")

</div>

Also i like this game

---

<div class="post-metadata">

**Author:** ![Harmanuary](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/harmanuary/32/21855_2.png) [@Harmanuary](https://forum.makecode.com/u/Harmanuary)\
**Post date:** [April 27, 2025, 4:05am UTC](https://forum.makecode.com/t/null-error-how/36140/6 "2025-04-27T04:05:51Z")

</div>

That works!

---

<div class="post-metadata">

**Author:** ![Harmanuary](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/harmanuary/32/21855_2.png) [@Harmanuary](https://forum.makecode.com/u/Harmanuary)\
**Post date:** [April 27, 2025, 4:05am UTC](https://forum.makecode.com/t/null-error-how/36140/7 "2025-04-27T04:05:56Z")

</div>

Glad to hear, it’s just a little side project to keep me busy and I like how it’s gone so I wanted to work on it a bit more.
