Hi yall this is the link to my code(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
3 Likes
AlexK
November 25, 2025, 6:39am
2
You’re setting gambling to your random value, but you’re testing against Choice. Use your gambling variable in your if() statements.
3 Likes
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
“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“
AlexK
November 25, 2025, 6:50pm
5
Use the debugger to understand your code better and to get at the source of your new error.
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.