How to obtain team leaderstats

In my games, the leadeboard displays how many kills a player has, it also displays the total amount of kills, a team has. For example, this might be the case of a leaderboard:

Player Kills
Team A 43
Player 1 40
Player 2 3
This always shows up, so I am wondering if there is a value assosicated with that, and if so, how can I obtain the team totals?
2 Likes

Maybe you only need to loop through every player from a team (I dont know how this works), I am going to show a way I think it would work.

local totalAmmount = 0
for i,v in pairs(team:GetPlayers()) do -- Loop through the team members
      totalAmmount = totalAmmount + v.leaderstats.Points.Value
end
print(totalAmmount) --Prints how much points in the max that team has
2 Likes

I am about 90% sure there is. I’m no liar, though.

1 Like

Just saw a thing on the Developer Hub so ill update my post.

(Updated it already.)

1 Like

What did you update? \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

I made it loop through the team players instead of looping through the players and checking if they are inside the team.

1 Like

Just loop through the players in the team:

local teamservice = game:GetService("Teams")
local team = Instance.new("Team", teamservice)
local totalkills = 0

for _, v in pairs(team:GetPlayers()) do
    local killstat = v.leaderstats.Kills
    totalkills += killstat.Value
end

print(totalkills)
2 Likes