I haven't really tried anything, I honestly wouldn't know where to start. If someone knows, it'd be greatly helpful :)
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