Team wins if other team has zero players ?
Asked by
7 years ago Edited 7 years ago
Hi, I am making a game where 1 player is chosen as a zombie and the rest are survivors.I am almost done with the scripting but I have one problem How do I check the number of players on the survivor team and if it is zero it does something.I only need a way to check the number of players nothing else
I made this code by using a free model for the intermission and following tutorials
local status = game.ReplicatedStorage:WaitForChild("Status")
while true do
status.Value = "Intermission!"
wait(5)
01 | function setTeam(player, Spectator) |
02 | player.TeamColor = game.Teams [ Spectator ] .TeamColor |
03 | if player.Character then |
04 | player.Character:BreakJoints() |
09 | for _, player in pairs (game.Players:GetPlayers()) do |
10 | setTeam(player, "Spectator" ) |
13 | local randomPlayer = game.Players:GetPlayers() [ math.random( 1 ,#game.Players:GetPlayers()) ] |
14 | randomPlayer.TeamColor = BrickColor.new( "Camo" ) |
16 | p = game.Players:GetChildren() |
18 | p [ i ] .Character.Head:remove() |
21 | status.Value = "Round in Progress" |
function setTeam(player, Spectator)
player.TeamColor = game.Teams[Spectator].TeamColor
if player.Character then --Just in case the character doesn't exist for some reason
player.Character:BreakJoints() -- Kills the players' character
end
end
--Changing everyone's team to "Reds"
for _, player in pairs(game.Players:GetPlayers()) do
setTeam(player, "Spectator")
end
status.Value = "Game Over!"
wait(5)
end