Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to get the best score of players?

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

2 comments

0

Your question suffers from the xy problem http://xyproblem.info

0

I'd like more background and context than this.

1 answer

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.