If every player has some value how do i make the top 3 people with the most value show up on #1, #2 and #3 text labels on one server after the game is over
I would first all of the players in the game with their value. U can do that with a for loop to get all players. After that u could set a max number value and have the closest people to that value be set up on the top 3.
Create a table with three 0 int elements.
Iterate over the players, check the values and compare against your table, save if higher and rearrange the top three as you iterate over the players.
To finish, access or create the text labels, and then set the relevant properties for whatever you need.
1. Iterate through the players in the game
5. To get your top 3 you can now use
local top1, top2 , top3 = x.player, x.player, x.player
6. Depending on how your code will be/is set up you can use a BindableEvent and optionally fire the playerName and stat and with that create your TextLabels
I hope this helped
You can use game.Players:GetPlayers() as your sorting table
I’m assuming there is a folder named ‘leaderstat’ parented to every table
local t = game.Players:GetPlayers() table.sort(t, function(a, b) a.leaderstat.Points.Value > b.leaderstat.Points.Value end) for i = 1, 3 do --Create text labels for t[i] player objects end