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
One thing I noticed is that you have name calling the function different from naming the function
for example -- you wrote
Waitforwinner() - the W is capitalized waitforwinner() -- nothing is capitalized here waitforwinner() --nothing is capitalized in here waitForWinner() -- the F is capitalized and the W is
These don't agree so i think you need to fix these and see if it helps.
Also I would call the first waitforwinner
as it will start the game and then after 420
seconds it will call the other one.