Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to sort by level?

Asked by 10 years ago

Right now I'm trying to sort a list of players by their level that is in their player

SortByLevel = function()
    local tab = {}
    for k,v in ipairs (game.Players:GetChildren()) do
        repeat wait() until v:FindFirstChild("Level")
        table.insert(tab,{v.Level.Value,v.Name})
    end
    table.sort(tab)
    for i = #game.Players:GetChildren(), 1, -1 do
        local n = tostring((#game.Players:GetChildren() - (i-1)))
        body:FindFirstChild(n).Text = n..". "..tab[n][2]
    end
end

So I get the error saying that the line where it sets the text is indexing a nil value, how do I fix this? I'm sure this is some simple solution I just have never made a leaderboard before...

0
Are you allowed to insert tables within tables using table.insert? VariadicFunction 335 — 10y
0
Why would you need to just make them separate tables and use the ""for i,v in pairs() do"" Kozero 120 — 10y
0
Where would I put the tables then? VariadicFunction 335 — 10y
0
How did I get down voted for the comment above? That makes no sense.... VariadicFunction 335 — 10y

Answer this question