How would I find the player with the highest leaderstats.Kills.Value and then print his name?
I don't want the script to collide when there are two players of the same Kill value, I'd appreciate any help :)
This is a simple optimization loop:
function getHighestKills() local players = game.Players:GetPlayers(); local bestSoFar = -1; local bestPlayer = nil; for i, player in pairs(players) do if player:FindFirstChild("leaderstats") and player.leaderstats:FindFirstChild("Kills") then if player.leaderstats.Kills.Value > bestSoFar then bestSoFar = player.leaderstats.Kills.Value; bestPlayer = player; end end end return bestPlayer; end