I’m getting an error called Instance < Instance, here’s the code:
local pets = {}
for x, c in pairs(eggPets:GetChildren()) do
table.insert(pets, c)
end
table.sort(pets)
I’m getting an error called Instance < Instance, here’s the code:
local pets = {}
for x, c in pairs(eggPets:GetChildren()) do
table.insert(pets, c)
end
table.sort(pets)
table.sort requires a metric to determine which element precedes the other. Instances themselves are just userdatas, and there is no known way of comparing them.
You need to compare a viable aspect of your pets in a predicate function, for example, their Names:
table.sort(pets, function(petA, petB)
return petA.Name > petB.Name
end)
petA.Name < petB.Name if you want the pets sorted alphabetically.