Output says "attempt to index local 'third' (a nil value)". How to make this work?
function leaderboard(first, second, third, fourth, fifth, sixth, seventh, eighth)
return first.leaderstats.Score.Value > second.leaderstats.Score.Value > third.leaderstats.Score.Value > fourth.leaderstats.Score.Value > fifth.leaderstats.Score.Value > sixth.leaderstats.Score.Value > seventh.leaderstats.Score.Value > eighth.leaderstats.Score.Value
end
local players = {}
for _, player in pairs(game.Players:GetPlayers()) do
if player:FindFirstChild("leaderstats") and
player.leaderstats:FindFirstChild("Score") then
table.insert(players, player)
end
end
table.sort(players, leaderboard)
if players[1] then
for _, player in pairs(game.Players:GetPlayers()) do
player.PlayerGui.ScreenGui.Frame.Visible = true
player.PlayerGui.ScreenGui.Frame.First.Text = "1. " .. players[1].Name
end
if players[2] then
for _, player in pairs(game.Players:GetPlayers()) do
player.PlayerGui.ScreenGui.Frame.Second.Text = "2. " .. players[2].Name
end
if players[3] then
for _, player in pairs(game.Players:GetPlayers()) do
player.PlayerGui.ScreenGui.Frame.Third.Text = "3. " .. players[3].Name
end
if players[4] then
for _, player in pairs(game.Players:GetPlayers()) do
player.PlayerGui.ScreenGui.Frame.Fourth.Text = "4. " .. players[4].Name
-- And So on...
end
end
end
end
end
Thanks!

4 comments
What line?
the output displayed line 2.
You have completely mis-understood my answer. You need to learn functions and think before making random changes
who is -repping every question