-
What do you want to achieve? Keep it simple and clear!
To make a script that checks who has the highest leaderstats value(wins in this case) and then prints the players name out along with how many wins they have. -
What is the issue? Include screenshots / videos if possible!
I don’t know where to start. -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I have tried Youtube and Devforum.
You could make a variable holding the name of the player with the highest wins. Then, loop through the players, checking to see if their wins is higher than the current highest wins. If so, replace the variable.
local highestWins = 0
local winner
for i, plr in pairs(game.Players:GetPlayers()) do
if plr.leaderstats.Wins.Value > highestWins then
highestWins = plr.leaderstats.Wins.Value
winner = plr.Name
end
end
if winner then
print(winner.." has the highest wins, with "..highestWins.." wins!")
else
-- do something if no one has the highest
end
Ok thanks so much, ill try this asap
1 Like
If it worked, please label it as a solution to let people know this has been solved.
Yep ill do that if it works
Thanks So Much! It Worked, I’m Making Your Post The Solution!!!
1 Like
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.