I was unsure where to post this but I don’t want my game moderated, so:
I have a table of weighted strings, yeah?
local rates = {
-- I removed the table after I got the solution
}
And I have this function to determine the outcome:
function m.GenerateRace()
local TotalWeight = 0
for i,v in pairs(rates) do
TotalWeight = TotalWeight + v[2]
end
local Chance = math.random(1, TotalWeight)
local Counter = 0
for i,v in pairs(rates) do
Counter = Counter + v[2]
if Chance <= Counter then
return v[1]
end
end
end
I learned that Roblox requires things that the players spend Robux on to have percentages. I don’t know how to calculate the percentages accurately and would really love the help! If there’s any more information needed or I’m just completely wrong, please let me know!