Formula with percentages?

I need to create a formula that takes in account percentage probability of something happening.

So it’s like

self.chance = 20

After that I need to have a 20 percent chance of calling a function.

How would I go about doing this? Because I’ve tried with math.randoms and Rand’s but it does not really work as I wanted it to.

if math.random(1,100) <= self.chance then


It seems my math.randoms were wrong :v:

Thanks mate, it works!

It’s math.random not math.randoms

math.randoms because I have been using more than one math.random.

function GetPercentage( num , Max ) return ( (num/Max)*100) end

Wow, didn’t think of that, bit late, but thanks!