function(PrizeTable)
local totalweight = 0
for _ , Data in PrizeTable do
totalweight += Data.Chance
end
local Chance = math.random(1,totalweight)
local Counter = 0
for i , Data in PrizeTable do
Counter += Data.Chance
if Chance <= Counter then
return Data
end
end
end
Well I am not sure if mine is good either, but what I have tried is loop from the best to worst and with a random number it should get selected WHEN the random number is 1. So basically if we have Rare 1/25 and the math.random(1,25) says 1, it gets selected.