Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I add a drop rate (chance to get item) from mobs in my RPG?

I am newish to scripting and would love to know how to do this with math.random, for example, you have a chance at getting the Holy Blade from killing this mob.

1 comment

0

doing something like if math.random(1,10) == 1 then comes to mind

1 answer

✓ Accepted answer

You want to create a variable for math.random(). Then the function will choose a random number between the given 1st value and 2nd value. Then the variable will be equal to that selected number.

Chance = math.random(1, 10)
if Chance == 1 then
	--Drop Holy Blade
end

You can of course change the values and variable.

Or you can do:

if math.random(1, 10) == 1 then
	--Drop Holy Blade
end

1 comment

0

also use math.randomseed() at the beginning lines of your code as normal math.random is not exactly random, there's an article on this: https://www.robloxdev.com/articles/Random-Number-Generation

This discussion is preserved as it was. New answers, comments, and votes are closed.