I made a script that grabs all the names of the players and their coins, puts it into a table and organizes it, and when I try to print the first row of the table in line 20, it only says nil in the output.
while true do
wait(3)
local playerlist = {
{"person", 24},
{"another person", 35}
}
local descendants3 = game.Players:GetChildren()
for index, descendant3 in pairs(descendants3) do
cash = descendant3.leaderstats:WaitForChild("Cash")
table.insert(playerlist, {descendant3.Name, cash.Value})
table.sort(playerlist, function(a,b)
local aNum = a[2]
local bNum = b[2]
return aNum > bNum
end)
for _, subTable in ipairs(playerlist) do
organized = table.unpack(subTable)
print(organized[1])
end
end
end
