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!