Stroke 95: attempt to iterate over a nil value

local newTable = EggData.Pets

print(typeof(newTable)) -- table

newTable = table.sort(newTable,function(a,b)
    
    return GlobalData.Pets[a].Chance > GlobalData.Pets[b].Chance
    
end)

print(newTable) -- turns nil

for Num,Pet in newTable do

module.Pets = {
Dog = {
Rarity = “Common”,
Chance = 1,
},
Cat = {
Rarity = “Uncommon”,
Chance = 35,
},

}

oh it was easy to solve,

table.sort(newTable,function(a,b)

return GlobalData.Pets[a].Chance > GlobalData.Pets[b].Chance

end)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.