How would i make this for loop loop through this table in order
local petTable = {
Bunny = 20,
Dog = 60,
Cat = 100,
}
for i, v in pairs(petTable) do
print(rng)
if rng <= v then
print(v)
selectedRarity = v
if v == 20 then
local pet = "Bunny"
costCheck(plr, pet)
elseif v == 60 then
local pet = "Dog"
costCheck(plr, pet)
elseif v == 100 then
local pet = "Cat"
costCheck(plr, pet)
end
break
end
rng -= v
end
I am trying to make it so it loops first bunny, then dog, then cat. However it keeps starting with dog. How would I do this?