I asked a similar question but I wasn't very specific. I made a game that picks random maps, picks random players for different teams **and has a LOBBY** to teleport to. I have 3 different teams with different colors. Each round lasts for 2 minutes or 120 seconds. I want to put the UNTIL around line 49 trying to say that the game ends early because of a player or players in a team dies. (The map vanishes back to Lighting and all players teleport to the lobby as shown in line 4)
team1 = CFrame.new(34.6, 3.09, 23.6)--change to where team1 spawns(red team) Note: use Vector3 cordinates team2 = CFrame.new(32, 3.09, -26.6)--change to where team2 spawns(blue team) team3 = CFrame.new(18.2, 0.59, 8.8)-- change to where team3 spawns lobby = CFrame.new(48.6, 169.7, -13)-- change the the position of the lobby(where the players go before/after the game) --weapon = game.Lighting["Sword"]-- change "Sword" to the name of the weapon you want players to have during the game. put the weapon in Lighting.if you want no weapons then remove this line. Maps = {"Map1","Map2","Map3"}-- change Map1,Map2,Map3 to the name of your maps and put them in Lighting. you can add more just add: ,"another map" after Map3 and so on. random = Maps[math.random(1,#Maps)] while true do wait(30)-- how long between games. script.map.Value = random local m = Instance.new("Message") m.Parent = game.Workspace m.Text = "" wait(5) m.Text = random.."" wait(4) g = game.Lighting[script.map.Value]:Clone() g.Parent = game.Workspace g:MakeJoints() m.Text = "Game starting" wait(3) m:remove() --d = weapon:Clone() --c = weapon:Clone() local pplz = game.Players:GetChildren() for i = 1,#pplz do if pplz[i].TeamColor == BrickColor.new("Bright red") and pplz[i] ~= nil and pplz[i].Character:FindFirstChild("Torso") ~= nil then-- change to team1's TeamColor --c.Parent = pplz[i].StarterGear --d.Parent = pplz[i].Backpack pplz[i].Character.Torso.CFrame = team1 --d = weapon:Clone() --c = weapon:Clone() elseif pplz[i].TeamColor == BrickColor.new("Deep blue") and pplz[i] ~= nil and pplz[i].Character:FindFirstChild("Torso") ~= nil then--change to team2's TeamColor pplz[i].Character.Torso.CFrame = team2 --d.Parent = pplz[i].Backpack --c.Parent = pplz[i].StarterGear elseif pplz[i].TeamColor == BrickColor.new("Pastel violet") and pplz[i] ~= nil and pplz[i].Character:FindFirstChild("Torso") ~= nil then--change to team3's TeamColor pplz[i].Character.Torso.CFrame = team3 --d.Parent = pplz[i].Backpack --c.Parent = pplz[i].StarterGear end end wait(120)-- how long each game lasts. local pplz = game.Players:GetChildren() for i = 1,#pplz do if pplz[i] ~= nil and pplz[i].Character:FindFirstChild("Torso") ~= nil then --local clean1 = pplz[i].StarterGear:GetChildren() --clean1[i]:remove() --local clean2 = pplz[i].Backpack:GetChildren() --clean2[i]:remove() pplz[i].Character.Torso.CFrame = lobby end end local m = Instance.new("Message") m.Parent = game.Workspace m.Text = "" wait(4) game.Workspace[script.map.Value]:remove() --m.Text = winner.." has won!" m:remove() end
I may be wrong, but it sounds like a coroutine could be of use.
Running = true Players = true coroutine.resume(coroutine.create(function() wait(120) Running = false end)) repeat --Blaah wait() until Running == false or Players == false