I wanted to make a round based game, and I wanted to have some code in the round script that would end the round and loop to the beginning of the round script, if there was one player on the Fighters team, or the time limit ends. It is pretty easy to implement one of these, but I cant wrap my head around making both of these statements fire independently. I have a feeling it requires a while loop though.
Here is my ENTIRE round script code:
--Main Variables repstorage = game.ReplicatedStorage teams = game.Teams teamsfolder = game.ReplicatedStorage.TeamsFolder weapons = game.ReplicatedStorage.Weapons --Round Variables local timeint = 5 local inttime = 5 local randotime = 5 local roundtime = 10 local startertime = 10 --Round Objects local status = game.ReplicatedStorage.StatusValue local map1 = repstorage.Maps.Map1 local map2 = repstorage.Maps.Map2 local map3 = repstorage.Maps.Map3 --Main while wait() do for i, player in ipairs(game.Players:GetPlayers()) do player.PlayerGui.Sound:Play() end for i = inttime,1,-1 do wait(1) status.Value = "Intermission: "..i.." Seconds." if i == 1 then status.Value = "Intermission: "..i.." Second." end end for i = timeint,1,-1 do wait(1) status.Value = "Choosing Map: "..i.." Seconds." if i == 1 then status.Value = "Choosing Map: "..i.." Second." end end local randomchance = math.random(1,3) if randomchance == 2 then for i = randotime,1,-1 do wait(1) status.Value = "Loading Gladiator Arena: "..i.." Seconds." if i == 1 then status.Value = "Loading Gladiator Arena: "..i.." Second." end map2.Parent = game.Workspace end end if randomchance == 1 then for i = randotime,1,-1 do wait(1) status.Value = "Loading Forest: "..i.." Seconds." if i == 1 then status.Value = "Loading Forest: "..i.." Second." end map1.Parent = game.Workspace end end if randomchance == 3 then for i = randotime,1,-1 do wait(1) status.Value = "Loading Temple: "..i.." Seconds." if i == 1 then status.Value = "Loading Temple: "..i.." Second." end map3.Parent = game.Workspace end end for i, player in ipairs(game.Players:GetPlayers()) do player.PlayerGui.Sound:Stop() if player.Character then local hum = player.Character:FindFirstChild('Humanoid') if hum then teamsfolder.Fencers.Parent = teams wait(0.1) player.TeamColor = teams.Fencers.TeamColor wait(0.1) player:LoadCharacter() wait(0.1) game.ReplicatedStorage.Weapons.Sabre:Clone().Parent = player.Backpack for i = startertime,1,-1 do wait(1) status.Value = "Game Starting In: "..i.." Seconds." player.PlayerGui.Sound4:Play() if i == 1 then status.Value = "Game Starting In: "..i.." Second." end end end end end for i, player in ipairs(game.Players:GetPlayers()) do player.PlayerGui.DeathScript.Disabled = false end for i, player in ipairs(game.Players:GetPlayers()) do player.PlayerGui.Sound.Playing = true end for i = roundtime,1,-1 do wait(1) status.Value = "Time: "..i.." Seconds." if i == 1 then status.Value = "Time: "..i.." Second." end end for i, player in ipairs(game.Players:GetPlayers()) do if player.Character then local hum = player.Character:FindFirstChild('Humanoid') if hum then player.Backpack:ClearAllChildren() for i = startertime,1,-1 do wait(1) status.Value = "Game Over!: "..i.." Seconds." if i == 1 then status.Value = "Game Over!: "..i.." Second." end end hum.Health = 0 wait(0.3) teams.Fencers.Parent = teamsfolder end end end for i, player in ipairs(game.Players:GetPlayers()) do player.PlayerGui.DeathScript.Disabled = true end if randomchance == 1 then game.Workspace.Map1.Parent = repstorage end if randomchance == 2 then game.Workspace.Map2.Parent = repstorage end if randomchance == 3 then game.Workspace.Map3.Parent = repstorage end end
I also have a hunch that I would need the following small snippet of code for something.
fencercount = game.Teams.Fencers:GetChildren()
Can anyone post a solution for immediate use, but also explain it so I can implement it myself next time?
Thanks for your help, and time.