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 11 years ago

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

01SortByLevel = function()
02    local tab = {}
03    for k,v in ipairs (game.Players:GetChildren()) do
04        repeat wait() until v:FindFirstChild("Level")
05        table.insert(tab,{v.Level.Value,v.Name})
06    end
07    table.sort(tab)
08    for i = #game.Players:GetChildren(), 1, -1 do
09        local n = tostring((#game.Players:GetChildren() - (i-1)))
10        body:FindFirstChild(n).Text = n..". "..tab[n][2]
11    end
12end

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 — 11y
0
Why would you need to just make them separate tables and use the ""for i,v in pairs() do"" Kozero 120 — 11y
0
Where would I put the tables then? VariadicFunction 335 — 11y
0
How did I get down voted for the comment above? That makes no sense.... VariadicFunction 335 — 11y

Answer this question