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

How can I make that the script counts the teams kills instead of the players kills?

Asked by 6 years ago

So yeah, thanks for those who can help. Well, I was trying to do a gamemode, like that it counts how many kills the teams got in a gui, seperately. So there is the blue one and the red one. Red one shows how many kills the red team got, and the blue shows how many kills the blue team got, basically the same thing. So I had a script that only counts the player kills, not the teams. When I tried to add that it only counts how many the team has killed, I didn't really find a way, so here I am. Anyone could help? Also for those who say I'm new to scripting, no I'm not, but I never have come up making a gamemode. Also here's the script for the player kill counter

local player = game.Players.LocalPlayer
local textlabel = script.Parent
while wait() do
textlabel.Text = player:WaitForChild("leaderstats"):WaitForChild("KOs").Value
end

How should I edit to it work as I want it?

0
Why use a while loop when you can use a .Changed event? awfulszn 394 — 6y
0
TL;DR SebbyTheGODKid 198 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago
local myTeam = game.Teams.NinjaSquad -- Your team
local groupcount = 0
for i,v in pairs(game.Players:GetChildren()) do
if v.Team == myTeam then
groupcount = groupcount + v.leaderstats.KOs.Value
end
end
print(groupcount)

Try that.

0
Thanks, pretty easy to modify the groupcount then to show in the gui. I'll hope somebody else can also use this. guidable 42 — 6y
0
Your welcome, always happy to help. ;D SebbyTheGODKid 198 — 6y
Ad

Answer this question