How would I sent the players leaderstats to the server so I can see who has the most leaderstats so I can see who won the game??
This should print out the player with the highest leaderstat named ‘Kills’
local Players = game:GetService('Players')
local function PrintTop(TopLeaderstat, Minimum)
local TopPlayer = {
['Player'] = nil,
['Value'] = Minimum
}
for _,Player in pairs(Players:GetPlayers()) do
local Leaderstats = Player:FindFirstChild('leaderstats')
if not Leaderstats then continue end
local WantedLeaderstat = Leaderstats:FindFirstChild(TopLeaderstat)
if not WantedLeaderstat then continue end
if WantedLeaderstat.Value > TopPlayer['Value'] then
TopPlayer['Player'] = Player
TopPlayer['Value'] = WantedLeaderstat.Value
end
end
if TopPlayer['Player'] then
print(TopPlayer['Player'].Name)
else
print('Everyone didnt meet the minimum value!')
end
end
PrintTop('Kills', -1)