How to have something have a random chance?

Like if somebody would have 1/4 chance to drop a certain item.

Just assign a random value to a variable.
For example:

Do= Random(3) to the value of variable Chance

It is going to return a random number range from 0 to 3 and you can just simply say.
If Chance = 2 then Drop the item, otherwise do nothing and this way the player has 1/4 chance to drop the item.

Now, one more problem (Sorry)

I can’t seem to figure out where or how to put that code in…
Help please. :confused:

When you set the value of a variable, you can enter the code as the value.


It called “expression” you can find many other expressions if you go to the expression editor by clicking that black symbol on the right side next to the value field. You can use expressions almost everywhere for advanced tasks.

But I strongly recommend to learn the basics first.
There are some tutorials on the wiki:
wiki.compilgames.net/doku.php/gdevelop/tutorials