Okay so i have a rarity system but i dont understand how i can actually have a accruate "1 in 125" system because the rarity i put for example the easiest pet as 45, is not a 1 in 45, should be a 1 in 1 right?
local ColorChances = {
-- COLOR, CHANCE, CHANCE NAME
{Color3.fromRGB(255, 0, 0), 40, "Common"};
{Color3.fromRGB(0, 255, 0), 30, "Rare"};
{Color3.fromRGB(0, 0, 255), 10, "Epic"};
}```
```lua
function ColorChances.getRandomIndex(self)
local totalChance = 0
for _, v in ipairs(self) do
totalChance = totalChance + v[2]
end
local randomNum = math.random() * totalChance
local accumulated = 0
for i, v in ipairs(self) do
accumulated = accumulated + v[2]
if randomNum <= accumulated then
return v
end
end
return self[1]
end```