Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-1

Random monster loot?

Asked by 10 years ago

Hey, I was wondering how can I make it so a monster drops random loot. i.e drops a bone 100%, gold 10%, sword 60% something like that. thank you in advance

1 answer

Log in to vote
0
Answered by 10 years ago

You would want to make use of the math.random function.

For example, if you wanted to make gold drop with a 10% chance, you could use the following:

-- If the random number is between 1 and 10, then:
if math.random(1, 100) <= 10 then
    -- drop gold
end
Ad

Answer this question