My players have a leaderstats with score, how to get the best score and put the name of the player with best score in a var?
I tried with getplayers () but it did not work
My players have a leaderstats with score, how to get the best score and put the name of the player with best score in a var?
I tried with getplayers () but it did not work
Here's a way to do this. This assumes you have standard leaderstats with Kills:
local Highscore = 0
for _,v in pairs(game:GetService("Players"):GetPlayers()) do
if v:FindFirstChild("leaderstats") and v.leaderstats:FindFirstChild("Kills") then
if v.leaderstats.Kills.Value > Highscore then
Highscore = v.leaderstats.Kills.Value
end
end
end
This discussion is preserved as it was. New answers, comments, and votes are closed.
2 comments
Your question suffers from the xy problem http://xyproblem.info
I'd like more background and context than this.