Team Kill Counter

I am trying to make a team kill counter for my game, I already figured out how to track a players kills, is there a way to track the whole teams kills?

You can update the label for the team kills anytime a given team member’s kill count is increased.

The total kills for a team can be calculated by just totaling all of the player’s kills.

local Teams = game:GetService("Teams")

local function get_team_score(team)
    local members = team:GetPlayers()
    local total = 0
    for _, player in pairs(members) do
        --// I don't know how you are tracking the kills,
        --// but here is an example if you were using leaderstats
        --// of course you can use any method you want. just grab the current player's kills.
        total += player.leaderstats.Kills.Value
    end
    return total
end

local team_a = Teams.A
local team_a_score = get_team_score(team_a)

print(team_a_score)
2 Likes

Im trying to make it to to this gui, how would I do that>
image

I gave you pretty much all the code you need? What is the issue?!

Just update the team score everytime a player of that team has their score is changed.

Use .Changed method, or just do it when you are directly setting the player’s new individual score.

I know someone already helped you but you should try to make your own script before making a post.