How to add a chance of something to spawn

Nov 16, 2021 - Hey guys, so im making a code which i will link below where you have to collect eggs, but i wanted to add something extra. So, every time you collect an egg, you get 1 point, but i wanted to add Golden Egg which would give you 5, but with only a 10% chance of spawning after collecting a previous egg. You will understand better if you play the game, if anyone can help me make that of send a screenshot.

Tysm, hope someone can help

1 Like

Welcome, @Evan1 !

You could do something like this:

The % chance block is in the Math drawer in the toolbox.

I created two different kinds for the sprites, Egg and SuperEgg. That way, you could handle them differently when needed. For example, since you want to assign different points to the sprites, you could use two different on sprite overlap event handlers.

Let us know if you need additional help.

1 Like