My script may be a bit messy, but I am wanting it to end when The bright red team players consist of 0, but if there are bright red team players still in existence I want the game to be able to last 5 minutes.
Here is my script:
while true do wait(100) local m = math.random(1,1) local player = game.Players:GetPlayers() local players = game.Players:GetChildren() game.Workspace.LoadingMap:Remove() game.ServerStorage.NextMap:clone().Parent = game.Workspace game.ServerStorage.WHPic:clone().Parent = game.Workspace game.ServerStorage.WareHouse:clone().Parent = game.Workspace game.ServerStorage.WHBlueSpawns:clone().Parent = game.Workspace game.ServerStorage.WHRedSpawns:clone().Parent = game.Workspace wait(5) game.Workspace.LobbyMusic:Remove() game.ServerStorage.Countdown:clone().Parent = game.Workspace wait(11.872) game.ServerStorage.TeamRandomizer:clone().Parent = game.Workspace wait(1) game.ServerStorage.TeleportWHBlue:clone().Parent = game.Workspace game.ServerStorage.TeleportWHRed:clone().Parent = game.Workspace game.Workspace.Countdown:Remove() wait(0.05) game.ServerStorage.TeamToolGiver:clone().Parent = game.Workspace game.ServerStorage.WHHostageDoor:clone().Parent = game.Workspace game.ServerStorage.WHMusic:clone().Parent = game.Workspace game.Workspace.NextMap:Remove() game.ServerStorage.CurrentMap:clone().Parent = game.Workspace game.Workspace.TeamRandomizer:Remove() wait() --game.ServerStorage.TimeIsClose:clone().Parent = game.Workspace local RedPlayers=0 function GetAmountOnRed() RedPlayers=0 local Players=game.Players:GetChildren() for _,Player in pairs(Players) do if Player.TeamColor==BrickColor.new("Bright red") then RedPlayers=RedPlayers+1 while script do wait() GetAmountOnRed() if RedPlayers==0 then game.Workspace.TeleportWHBlue:Remove() game.Workspace.TeleportWHRed:Remove() game.Workspace.WHBlueSpawns:Remove() game.Workspace.WHRedSpawns:Remove() game.Workspace.WHPic:Remove() --game.Workspace.TimeIsClose:Remove() game.Workspace.WHMusic:Remove() game.Workspace.WareHouse:Remove() game.Workspace.CurrentMap:Remove() wait(1) game.ServerStorage.LobbyMusic:Clone().Parent = game.Workspace game.ServerStorage.LoadingMap:clone().Parent = game.Workspace else wait(300) end end end
All the scripts I paste into workspace auto remove themselves.
To check if there are members of a team still alive, consider the following:
You can change their team upon their death, and you can add a .Died event firing everytime someone dies to check if the team is going to be "empty".
You can add a BoolValue in every player that says if he is dead (use a .Died event to check the box), and you can do a couple of for loops like so:
local function checkIfAllDead() local redteam={} for i,v in pairs(game.Players:GetChildren()) do if v.TeamColor=BrickColor.new("Bright red") then redteam[#redteam+1]=v for index,teamMember in pairs(redteam) do if teamMember.IsDead==false then return false; end end end return true; end
I believe that would work
!EDIT! Don't forget to make a script adding the IsDead value tho, and set it to false every time a round begins. I never did a round system or whatever so idk if that's the most efficient way.