At the end of the round, you go through all the player’s values. Sort it then you’ve got the most kills.
Their kills reset at the end of the sorting.
local KillsTable = {}
function SortKills()
for i, v in pairs(game.Players:GetChildren()) do
table.insert(KillsTable, v.Kills.Value)
end
--then do table.sort here
end
--when round ends
SortKills()
--then set all the players kills to 0
That should work with any numbers, it will sort all of the player’s kills that are present at the end of the round. Do you simply just want to get the one person with the most kills or do you want to create a leaderboard?
function GetPersonWithMostKills()
local current, plr = 0, nil
for i, v in pairs(game.Players:GetChildren()) do
if v.Kills.Value > current then
plr = v
end
end
return plr
end
--when round ends
PlayerWithMostKills = GetPlayerWithMostKills()
Yes it would, that’s a very basic interpretation of it though. if you have leaderstats, v.Kills.Value becomes v.leaderstats.Kills.Value since what you’re doing is Player.leaderstats.Kills.Value
'''
function GetPlayerWithMostKills()
local current, plr = 0, nil
for i, v in pairs(game.Players:GetChildren()) do
if v.Kills.Value > current then
plr = v
end
end
return plr
end
--when round ends
PlayerWithMostKills = GetPlayerWithMostKills()
Also, how would you show the player who got the most kills avatar? (I already have a script for showing the avatar. But I need it to show if the player got the most kills, and if the round is over)