I'm attempting to write a script where it takes the table and sorts out the lap number from highest to lowest. The thing is, it correctly prints out the first player, but the players afterwards bug out.
Table script:
local allPlayers = game.Players:GetPlayers()
table.sort(allPlayers, function(a, b)
return a.Lap.Value > b.Lap.Value
end)
while wait(0.001) do
for i,v in next, allPlayers do
print(v.Name .. ": " .. i .. "th")
end
end
PlayerInstance script:
local allPlayers = game.Players:GetPlayers()
local test = game.Players.LocalPlayer:GetFullName()
for _, player in pairs(allPlayers) do
if player.Character then
if test ~= "Player.Sxerks2" then
-- was only a test
local lapNum = Instance.new("IntValue", game.Players.LocalPlayer)
lapNum.Name = "Lap"
lapNum.Value = 2
end
local lapNum = Instance.new("IntValue", game.Players.LocalPlayer)
lapNum.Name = "Lap"
lapNum.Value = 1
local checkpoint = Instance.new("IntValue", game.Players.LocalPlayer)
checkpoint.Name = "Checkpoint"
checkpoint.Value = 0
end
end
Thanks!

3 comments
What is this "table?" Is it part of the leader board? Or is it an object. If it is a part, then you need to put workspace.table
Wait... what!?? table.sort? Has that always been a thing?
@NewVoids Yeah, lol. It sorts data in a table by numerical order, then alphabetical order.