First of all, hello.
I want to make a percentege system for my game, the problem? I can’t figure out how to make it.
Example on what i want to do:
Loot1: 25%
Loot2: 50%
Loot3 = 30%
Loot4 = 10%
Thanks for reading.
First of all, hello.
I want to make a percentege system for my game, the problem? I can’t figure out how to make it.
Example on what i want to do:
Loot1: 25%
Loot2: 50%
Loot3 = 30%
Loot4 = 10%
Thanks for reading.
U could use math.random(x, y)
for example. 25% = (1, 4) . 50% = (1, 2) You would want the function to find the number 1.
The solution here should help you.
How do i make a chance system? - Help and Feedback / Scripting Support - DevForum | Roblox
i dont think math.random would be a good option because It’s completly random ut i will try it, thanks
math.random would be a good option, and I have helped making loot tables before, but here’s an example:
local loottable = {
Loot1 = 25,
Loot2 = 25,
Loot3 = 30,
Loot4 = 10
}
local totalrarity = 0
for i,v in pairs(loottable) do totalrarity += v end
function getloot()
local lootnum = math.random(totalrarity)
local currentrarity = 0
for i,v in pairs(loottable) do
currentrarity += v
if lootnum <= currentrarity then return i end
end
end
print(getloot())
Now, there are multiple other ways to make the table, but this is just one going based off of how you provided the loot system.
Thanks, this is perfect, I’m using that system