Sprite only listens sometimes

I have a sprite that is supposed to glide off screen under certain conditions, but it only does so like 50% of the time. I’m resetting with the green flag each time, so I’m not sure what the reason is.

The sprite is the tennis paddle. After you select the first color, it should go away, but it doesn’t always.

The problem is with this block:


The way it is written, there is a 1 out of 4 chance it will not do anything. I recommend using a script variable instead:

This way there will be no chance of it not running.

Also, change the pick random block to pick random from 1 to 4 instead of 2. This way, all of the options are possible, not just the ones testing for equality to 1 and 2.

Thank you! But how is this functionally different from what I did? I’d like to understand so I can avoid this kind of mistake in the future.

Using a script variable makes it so the number is one set number; it doesn't change. With what you did, it picks a new random number every time.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.