I haven't really tried anything, I honestly wouldn't know where to start. If someone knows, it'd be greatly helpful :)
COMMUNITY QUESTION
What script would I use to call for the player with the most kills on a leaderboard?
1 answer
Assuming the default leaderboard is used, we can assume that each Player's kills are stored in IntValues within an IntValue called 'leaderstats' within their Player object.
Basically, Players.adark.leaderstats.Kills.Value would get my kills.
To look at every player, we need to loop through them. We set a variable called topKills to record the player with the most kills, and check if the next player we find has more kills that them. At the end, we return that player with the most kills:
function getTopKills()
local topKills
for _, plr in ipairs(game.Players:GetPlayers()) do
if not topKills or topKills.leaderstats.Kills.Value < plr.leaderstats.Kills.Value then
topKills = plr
end
end
return topKills
end
This discussion is preserved as it was. New answers, comments, and votes are closed.
