Show player choices

Hello community,

I’m making a sailing game. I’m trying to let the player choose different skins of boats at the beginning. I know that there is a way to make the actual sprites appear, but I kind of want to surprise the player. Also it’s a bit annoying to do it that way. Anyhow, I’m having an error with my code here:

It lies in the first show player choices block. The game works fine (the boat doesn’t spawn with an image though, due to it not being defined) without this block, but with the block it’s giving me a “sim error: failed cast on null.” Please help ASAP!

Thanks,

DatCaptainNemo

project link: https://arcade.makecode.com/S15609-42312-11259-01967

1 Like

You simply forgot about this not really checking when the game has started for this script:

Since it’s mapped to the button A, it makes the nonexistent boat shoot the cannonball, which causes a cast on null. The reason it only happens when a choice is being made because the built-in text showing methods disable the On ? Pressed events. Make a variable that is only true after the game starts and use that to also check if a cannonball should be shot.