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