Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

A team's leaderstat?

Asked by 9 years ago

Is there a way to access a team's leaderstat, such as KOs, instead of a single player's leaderstat?

1 answer

Log in to vote
3
Answered by
dyler3 1510 Moderation Voter
9 years ago

You could always just go through all of the players leaderstats, and add up the values. Given, that the player is on that certain team of course. Here's an example:

Team="Bright blue"
Plrs=game.Players:GetPlayers()

while wait(1) do --Repeats the process every second
    local TotalKills=0 --Sets the variable to add to
    for i=1,#Plrs do --Cycles through each player
        if Plrs[i].TeamColor=Team then --Finds if the player is on the desired team or not.
            TotalKills=TotalKills+Plrs.leaderstats.Kills.Value --Adds up the teams current kill count
        end
    end
    print("Total kills for "..Team.." team: "..TotalKills) --Prints out the total kills for the team
end

This would work good if you were just trying to print out the kills on a certain team. Anyways, this is just an example, so if you need any more clarification, please leave a comment below. Hope I helped :P

0
I edited it to work, so I'll accept it as the answer. Thanks for helping! jimborimbo 94 — 9y
0
No prob, glad I could help :P dyler3 1510 — 9y
Ad

Answer this question