You can use table.sort to sort an array containing every player and their points into a descending order, that way you can retrieve the first, second and third player by just using their position(for example the first player is players[1]):
local Players = game:GetService("Players")
--convert all the players and their points into an array
function getPlayersArray()
local players = {}
for _, p in pairs(Players:GetPlayers()) do
local points = p:FindFirstChild("Points") --change this to the points location
table.insert(players, {player = p, Points = points})
end
return players
end
local players = getPlayersArray()
--sort the array(that's why we used arrays instead of dictionaries)
table.sort(players, function(a, b)
return a.Points > b.Points
end)
--print the array in the sorted order
for _, v in pairs(players) do
print(v.player, v.Points)
end
local first = players[1] --since the array is sorted, the first player has the highest points
local second = players[2]
local third = players[3]
--etc.
print(first.player, first.Points)