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)

2 comments
My brain is mush, can you specify which function you want to stop?
Oh my god I accidently left some left over code in it! I fixed it, sorry for the miscommunication. I want the roundTimer function to restart. On line 48 is where a restart script would go for the function, I just don't know what to use to restart it.