Hello! Today I was making code for a minigame I was going to make. I've got the main basics set already, it's just when I want the round to end, I can't stop the function. This makes it continue for 600 seconds when the last person is alive. Any tips? I tried everything before going on the website, I really didn't want to waste any of your guy's time.
local roundLength = 600 local intermissionLength = 10 local InRound = game.ReplicatedStorage.InRound local GameAreaSpawn = game.Workspace.GameAreaSpawn local SpawnArea = game.Workspace.SpawnArea local Status = game.ReplicatedStorage.Status InRound.Changed:Connect(function() if InRound.Value == true then for _, player in pairs(game.Players:GetChildren()) do local char = player.Character char.HumanoidRootPart.CFrame = GameAreaSpawn.CFrame end else for _, player in pairs(game.Players:GetChildren()) do local char = player.Character char.HumanoidRootPart.CFrame = SpawnArea.CFrame end end end) local function roundTimer() while wait() do for i = intermissionLength, 1, -1 do InRound.Value = false wait(1) Status.Value = "Intermission: ".. i .." seconds left" end for i = roundLength, 1, -1 do InRound.Value = true wait(1) Status.Value = "Game: ".. i .." second left!" end end end spawn(roundTimer) game:GetService('Players').PlayerAdded:Connect(function(player) player.CharacterAdded:Connect(function(character) character:WaitForChild("Humanoid").Died:Connect(function() if player.Team == game.Teams.PlayersTeam then player.Team = game.Teams.ViewersTeam local playeramount = game.Teams.PlayersTeam:GetPlayers() if #playeramount == 1 then print"You WON!!!!" wait(3) --Right here is where i need the round timer to stop and go back to intermission end end end) end) end)
I actually figured it out, sorry for the request! Heres a snippet of the code that worked incase anyone skims over this thread when its ended. Works like a charm :)
for i = roundLength, 1, -1 do InRound.Value = true wait(1) Status.Value = "Game: ".. i .." second left!" local playeramount = game.Teams.PlayersTeam:GetPlayers() if #playeramount == 1 then wait(4) --INSERT FOR WHEN PLAYER WINS break else print(#playeramount) end