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

How do I check if everyone on a team dies once?

Asked by 4 years ago

So I wan't to make a team based sword game where if all the players in the opposing team dies the other team will win, so I wan't to know how do I check if everyone on a team has already died once and declare the opposing team the victory.

1
Iterate through each team list by using Team:GetPlayers() in conjunction with a pairs loop. Connect a .Died event to each Humanoid. You can set up your own method of keeping record of every death, and checking if all have died. Ziffixture 6913 — 4y

1 answer

Log in to vote
0
Answered by
imKirda 4491 Moderation Voter Community Moderator
4 years ago

I mean easy way is if someone dies from the team it will change his team to 'Neutral' or 'Lobby' something like that and then you check if it will find any children in the team, if no then everyone has died. To check it here is example script:

local children = game.Teams.RedTeam:GetChildren() -- change that
if #children == 0 -- if there is no children
    then print("everyone has died this team")
    end
0
Thanks for the answer, I changed the GetChildren part to GetPlayers and it seems to be working fine :D habloshom 9 — 4y
Ad

Answer this question