I made a race reroll system but there is some things that I can't get. I can't get Race 7, 8, and 9. Here's the script :
local racesTable = {
['Human'] = 40,
['Race2'] = 25,
['Race3'] = 11,
['Race4'] = 9.99,
['Race5'] = 5,
['Race6'] = 5,
['Race7'] = 2,
['Race8'] = 2,
['Race9'] = 0.01,
}
local TotalWeight = 0
for Piece, Weight in pairs(racesTable) do
TotalWeight = TotalWeight + Weight
end
local Chance = math.random(1, TotalWeight)
local Counter = 0
for Piece, Weight in pairs(racesTable) do
Counter = Counter + Weight
if Chance <= Counter then
PlayerData.Race.Value = Piece
return Piece
end
end