# Can yall please help me

**URL:** <https://forum.makecode.com/t/can-yall-please-help-me/40652>\
**Category:** Help\
**Created:** [November 25, 2025, 6:38am UTC](https://forum.makecode.com/t/can-yall-please-help-me/40652 "2025-11-25T06:38:32Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Malnotle](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/malnotle/32/26750_2.png) [@Malnotle](https://forum.makecode.com/u/Malnotle)\
**Post date:** [November 25, 2025, 6:38am UTC](https://forum.makecode.com/t/can-yall-please-help-me/40652/1 "2025-11-25T06:38:32Z")

</div>

Hi yall this is the link to my code([https://arcade.makecode.com/S24899-53111-65016-91949](https://arcade.makecode.com/S24899-53111-65016-91949))

The problem I am running into is that when I say pick random between 0 and 4 it always picks 0 and I don’t know why. here’s a photo of the code, Any help would be useful, Thanks

 ![Screenshot 2025-11-24 at 22.20.59](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/3X/2/d/2d5b048b4d35d5ff05c87852c721f98f79af2e2b.png)

---

<div class="post-metadata">

**Author:** ![AlexK](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/alexk/32/33339_2.png) [@AlexK](https://forum.makecode.com/u/AlexK)\
**Post date:** [November 25, 2025, 6:39am UTC](https://forum.makecode.com/t/can-yall-please-help-me/40652/2 "2025-11-25T06:39:12Z")

</div>

You’re setting `gambling` to your random value, but you’re testing against `Choice`. Use your `gambling` variable in your `if()` statements.

---

<div class="post-metadata">

**Author:** ![Malnotle](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/malnotle/32/26750_2.png) [@Malnotle](https://forum.makecode.com/u/Malnotle)\
**Post date:** [November 25, 2025, 6:17pm UTC](https://forum.makecode.com/t/can-yall-please-help-me/40652/3 "2025-11-25T18:17:00Z")

</div>

Thanks for letting me know, but unfortunately I tried doing what you said and it gave me a null error. Do you know why that is, Thanks

---

<div class="post-metadata">

**Author:** ![Ima.notarobot](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/ima.notarobot/32/26551_2.png) [@Ima.notarobot](https://forum.makecode.com/u/Ima.notarobot)\
**Post date:** [November 25, 2025, 6:24pm UTC](https://forum.makecode.com/t/can-yall-please-help-me/40652/4 "2025-11-25T18:24:22Z")

</div>

“_ **LETS GO GAMBLING** _” -@Malnotle

But to put @AlexK’s words simpler your issue is that when asking gambling variable to pick a random 0-4, instead of asking gambling is = 0 if else gambling = 1 ect, you have a random variable “Choice“

---

<div class="post-metadata">

**Author:** ![AlexK](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/alexk/32/33339_2.png) [@AlexK](https://forum.makecode.com/u/AlexK)\
**Post date:** [November 25, 2025, 6:50pm UTC](https://forum.makecode.com/t/can-yall-please-help-me/40652/5 "2025-11-25T18:50:57Z")

</div>

Use the debugger to understand your code better and to get at the source of your new error.

> [@Program error: sim error: failed cast on null](https://forum.makecode.com/t/program-error-sim-error-failed-cast-on-null/28831/2):
>
> Hi, @ruprion ! Whenever I get an error like this, especially when the error is repeatable (meaning, I know when the error will happen), then I often use the debugger to show me where the problem is. To turn on the debugger, select the debug button below the game controls. Screenshot below. [Debug button highlighted beneath the MakeCode Arcade simulator] When I run the debugger on your program and select the A button after the attract screen, the debugger highlights this block inside of your o…

More than likely, one of your `ItemX()` functions is trying to work with a sprite that has not yet been created.

---

<div class="post-metadata">

**Author:** ![Malnotle](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/malnotle/32/26750_2.png) [@Malnotle](https://forum.makecode.com/u/Malnotle)\
**Post date:** [November 25, 2025, 7:37pm UTC](https://forum.makecode.com/t/can-yall-please-help-me/40652/6 "2025-11-25T19:37:26Z")

</div>

Ok, Thanks so much
