My question is why won't the round end and go back to the lobby when all players have died? It won't go back to intermission and close the map again. I've been trying for hours on end so if anyone could help here's my script:

local MapsFolder = game.ReplicatedStorage:WaitForChild("Maps")
local Status = game.ReplicatedStorage:WaitForChild("Status")

while true do
	Status.Value = "Intermission 30"
	local interTime = 30
	repeat wait()
		wait(1)
		interTime = interTime - 1
		Status.Value = "Intermission "..interTime
	until interTime <= 0
	wait(1)
	Status.Value = "Selecting a map"

	local mapId = math.random(1,#MapsFolder:GetChildren())
	local map = MapsFolder:FindFirstChild("Map"..mapId)

	wait(1)
	if map then
		Status.Value = "Map has been chosen"

		local mapName = map:FindFirstChild("MapName")
		if mapName then
			Status.Value = "Chosen map: "..mapName.Value
		else
			Status.Value = "The map doesn't have a name"
		end
		wait(2)
		Status.Value = "Loading map..."

		local newMap
		newMap = map:Clone()
		newMap.Parent = workspace
		newMap.Name = "Map"

		wait(2)

		Status.Value = "Teleporting players..."

		local players = 0
		if newMap:FindFirstChild("PlayerSpawns") then
			for i,v in pairs(game.Players:GetPlayers()) do
				local character = workspace:FindFirstChild(v.Name)
				if character then
					local rootPart = character:FindFirstChild("HumanoidRootPart")
					if rootPart then
						local spawnId = math.random(1,#newMap.PlayerSpawns:GetChildren())
						local spawnObj = newMap.PlayerSpawns:FindFirstChild("Spawn"..spawnId)

						if spawnObj then
							players = players + 1
							rootPart.Position = spawnObj.Position
						end
					end
				end
			end
			wait(2)
			Status.Value = "The round is starting" --The value is Status is the text for this
			wait(2)
			local wave = 1
			local zombies = 0

			repeat wait()
				Status.Value = "Wave ".. wave.. "!"
				wait(2)

				local waveFolder = game.ReplicatedStorage:WaitForChild("Waves"):FindFirstChild("Wave".. wave)
				if waveFolder then
					for i, v in pairs(waveFolder:GetChildren()) do
						local clone = v:Clone()

						local rootPart = clone:FindFirstChild("HumanoidRootPart")
						if rootPart then
							clone.Parent = workspace

							local spawnObj = map:FindFirstChild("ZombieSpawns")
							if spawnObj then
								local spawnChild = spawnObj:GetChildren()

								local spawnPos = spawnChild[math.random(1, #spawnChild)]

								if spawnPos:IsA("BasePart") then
									rootPart.CFrame = spawnPos.CFrame
									zombies = zombies + 1
								end
							end
						else
							clone:Destroy()
						end
					end
				else
					for i = 1, math.random(wave - 1, wave) do
						local zFolder = game.ReplicatedStorage:WaitForChil("Zombies")
						local zombie = zFolder:GetChildren()[math.random(1, #zFolder:GetChildren())]

						local rootPart = zombie:FindFirstChild("HumanoidRootPart")
						if rootPart then
							local posses = map:FindFirstChild("ZombieSpawns")
							if posses then
								local pos = posses:GetChildren()[math.random(1, #posses:GetChildren())]
								if pos:IsA("BasePart") then
									rootPart.CFrame = pos.CFrame
									zombies = zombies + 1
								end
							end
						end
					end
				end
				repeat wait() until zombies <= 0

				wave = wave + 1
			until players <= 0 or wave == 100

		else
			Status.Value = "Map doesn't have spawns! Can't load"
		end
	else
		Status.Value = "Failed to find a map"
	end 


	wait(5)
	if workspace:FindFirstChild("Map") then
		workspace.Map:Destroy()
	end

	wait(2)
end