I have two separate pieces of script here. Basically it displays a message if the team "survivors" has no players left(waitforwinner function). It works only when a single player is on but when I tried to play with someone who else at the same time it failed to display the message
function Waitforwinner()
wait(420)
if #getTeam(game.Teams.Survivors) >= 1 then
local m = Instance.new("Message", Workspace)
m.Text = "Time has run out. Survivors win!"
wait(3)
m:Destroy()
for i,v in pairs(game.Players:GetPlayers()) do
v.Character.Humanoid.Health = 0
v.TeamColor = BrickColor.new("Bright blue")
wait(5)
v.Character.Humanoid.WalkSpeed = 0
begin("Beginning the round now!You will have 15 seconds before a player is randomly infected.",3)--function begin
respawn()
FirstInfected("A player has been randomly infected!",3)
waitforwinner()
waitForWinner()
end
end
end
function waitforwinner()
if #getTeam(game.Teams.Survivors) == 0 then
m = Instance.new("Message",Workspace)
m.Text = "The final survivor was infected. Once you respawn the round will begin!"
wait(3)
m:Destroy()
for i,v in pairs(game.Players:GetPlayers()) do
if v.TeamColor == BrickColor.new("Bright orange") then
v.StarterGear.Revolver:remove()
end
v.Character.Humanoid.Health = 0
wait(1)
v.TeamColor = BrickColor.new("Bright blue")
wait(5)
begin("The round has begun.",3)
GiveGun()
FirstInfected("A player has been randomly infected!",3)
waitforwinner()
waitForWinner()
end
end
end
waitforwinner()
waitForWinner()
Any reasons why this wouldn't work? Thanks

3 comments
What do you mean?
@wjs3456 which message did if fail to print?
The final survivor was infected. Once you respawn the round will begin