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 10 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
10 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:

01Team="Bright blue"
02Plrs=game.Players:GetPlayers()
03 
04while wait(1) do --Repeats the process every second
05    local TotalKills=0 --Sets the variable to add to
06    for i=1,#Plrs do --Cycles through each player
07        if Plrs[i].TeamColor=Team then --Finds if the player is on the desired team or not.
08            TotalKills=TotalKills+Plrs.leaderstats.Kills.Value --Adds up the teams current kill count
09        end
10    end
11    print("Total kills for "..Team.." team: "..TotalKills) --Prints out the total kills for the team
12end

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 — 10y
0
No prob, glad I could help :P dyler3 1510 — 10y
Ad

Answer this question