Round system intermission broken

i have a round system but the intermission is broken as it says the negaive number

local status = game:GetService("ReplicatedStorage"):FindFirstChild("Status")
local maps = game.Workspace.Maps:GetChildren()
local interTime = 10 --Intermission Time
local roundTime = 10
local PlayerNeeded = 1
while true do wait()
	for i,v in pairs(game.Players:GetPlayers()) do
		if i >= PlayerNeeded then

			while true do --intermission loop
				status.Value = "Intermission "..interTime
				if interTime >= 0 then
					interTime = interTime - 1
				end
				wait(1)

				if interTime == 0 then
					break
				end
			end

			status.Value = "Round Starting.."

			local chosenMapNumber = math.random(1,#maps)--picks a random map
			local chosenMap = maps[chosenMapNumber]
			local TpRed = chosenMap.Spawns.RedSpawns:GetChildren()
			local TpBlue = chosenMap.Spawns.BlueSpawns:GetChildren()

			for i, player in pairs(game.Players:GetChildren()) do
				local char = player.Character
				if player.TeamColor == BrickColor.new("Really red") then
					print("red team")
					local tool = game.ServerStorage.Tools:GetChildren()
					local random = tool[math.random(1,#tool)]
					local cloned = random:Clone()
					cloned.Parent = player.Backpack
					char:WaitForChild("Humanoid"):EquipTool(cloned)
					char.HumanoidRootPart.CFrame =  TpRed[math.random(1,#TpRed)].CFrame * CFrame.new(0,3,0)
				elseif player.TeamColor == BrickColor.new("Really blue") then
					print("blue team")
					local tool = game.ServerStorage.Tools:GetChildren()
					local random = tool[math.random(1,#tool)]
					local cloned = random:Clone()
					cloned.Parent = player.Backpack
					char:WaitForChild("Humanoid"):EquipTool(cloned)
					char.HumanoidRootPart.CFrame =  TpBlue[math.random(1,#TpBlue)].CFrame * CFrame.new(0,3,0)
				end
			end

			while true do --round loop
				status.Value = "Round "..roundTime

				roundTime = roundTime - 1

				wait(1)

				if roundTime <= 0 then
					break
				end
			end

			for i, player in pairs(game.Players:GetChildren()) do
				if not player:FindFirstChildOfClass("Tool") then
					player:LoadCharacter()
				else
					player.Character:WaitForChild("Humanoid"):UnequipTools()
					player:FindFirstChildOfClass("Tool"):Destroy()
					player:LoadCharacter()
				end
			end

		else
			print("not enough!")
		end
	end
end
1 Like

That might be the problem. In terms of Logic if the Intermission Time is greater or equal to 0, then subtract 1. However, you are checking to see if the Intermission Time is exactly 0 to break.

So I’d recommend either changing it to:

if interTime > 0 then
--Subtract

or

if interTime <= 0 then
--Break

after looking on your post i made this

local status = game:GetService("ReplicatedStorage"):FindFirstChild("Status")
local maps = game.Workspace.Maps:GetChildren()
local interTime = 10 --Intermission Time
local roundTime = 20
local PlayerNeeded = 1
while true do wait()
	for i,v in pairs(game.Players:GetPlayers()) do
		if i >= PlayerNeeded then

			while true do --intermission loop
				status.Value = "Intermission "..interTime
				if interTime > 0 then
					interTime = interTime - 1
				end
				wait(1)

				if interTime <= 0 then
					break
				end
			end

			status.Value = "Round Starting.."

			local chosenMapNumber = math.random(1,#maps)--picks a random map
			local chosenMap = maps[chosenMapNumber]
			local TpRed = chosenMap.Spawns.RedSpawns:GetChildren()
			local TpBlue = chosenMap.Spawns.BlueSpawns:GetChildren()

			for i, player in pairs(game.Players:GetChildren()) do
				local char = player.Character
				if player.TeamColor == BrickColor.new("Really red") then
					print("red team")
					local tool = game.ServerStorage.Tools:GetChildren()
					local random = tool[math.random(1,#tool)]
					local cloned = random:Clone()
					cloned.Parent = player.Backpack
					char:WaitForChild("Humanoid"):EquipTool(cloned)
					char.HumanoidRootPart.CFrame =  TpRed[math.random(1,#TpRed)].CFrame * CFrame.new(0,3,0)
				elseif player.TeamColor == BrickColor.new("Really blue") then
					print("blue team")
					local tool = game.ServerStorage.Tools:GetChildren()
					local random = tool[math.random(1,#tool)]
					local cloned = random:Clone()
					cloned.Parent = player.Backpack
					char:WaitForChild("Humanoid"):EquipTool(cloned)
					char.HumanoidRootPart.CFrame =  TpBlue[math.random(1,#TpBlue)].CFrame * CFrame.new(0,3,0)
				end
			end

			while true do --round loop
				status.Value = "Round "..roundTime

				roundTime = roundTime - 1

				wait(1)

				if roundTime <= 0 then
					break
				end
			end

			for i, player in pairs(game.Players:GetChildren()) do
				if not player:FindFirstChildOfClass("Tool") then
					player:LoadCharacter()
				else
					player.Character:WaitForChild("Humanoid"):UnequipTools()
					player:FindFirstChildOfClass("Tool"):Destroy()
					player:LoadCharacter()
				end
			end

		else
			print("not enough!")
		end
	end
end

and it prints normally and after going into round finishes the intermission is saying 0
so it prints

  Intermission 9 (x12)  -  Client - LocalScript:3
  12:48:11.786  Intermission 8 (x20)  -  Client - LocalScript:3
  12:48:12.780  Intermission 7 (x16)  -  Client - LocalScript:3
Intermission 7 (x2)  -  Client - LocalScript:3
  12:48:13.969  Intermission 6  -  Client - LocalScript:3
  Intermission 6 (x6)  -  Client - LocalScript:3
  12:48:15.301  Intermission 5 (x6)  -  Client - LocalScript:3
  12:48:16.120  Intermission 4 (x8)  -  Client - LocalScript:3
  12:48:17.105  Intermission 3 (x10)  -  Client - LocalScript:3
  12:48:18.103  Intermission 2 (x11)  -  Client - LocalScript:3
  12:48:19.277  Intermission 1 (x8)  -  Client - LocalScript:3
  12:48:20.032  red team  -  Server - RoundsSystem:32
  12:48:20.113  Intermission 1  -  Client - LocalScript:3
  12:48:20.218  Round 20 (x7)  -  Client - LocalScript:3
  12:48:21.252  Round 19 (x5)  -  Client - LocalScript:3
  12:48:22.772  Round 18 (x4)  -  Client - LocalScript:3
  12:48:23.736  Round 17 (x4)  -  Client - LocalScript:3
  12:48:24.843  Round 16 (x4)  -  Client - LocalScript:3
  12:48:25.968  Round 15 (x5)  -  Client - LocalScript:3
  12:48:27.215  Round 14 (x4)  -  Client - LocalScript:3
  12:48:28.443  Round 13 (x4)  -  Client - LocalScript:3
  12:48:29.669  Round 12 (x4)  -  Client - LocalScript:3
  12:48:30.681  Round 11 (x5)  -  Client - LocalScript:3
  12:48:31.937  Round 10 (x4)  -  Client - LocalScript:3
  12:48:32.949  Round 9 (x4)  -  Client - LocalScript:3
  12:48:34.173  Round 8 (x3)  -  Client - LocalScript:3
  12:48:35.071  Round 7 (x6)  -  Client - LocalScript:3
  12:48:36.272  Round 6 (x6)  -  Client - LocalScript:3
  12:48:37.312  Round 5 (x5)  -  Client - LocalScript:3
  12:48:38.368  Round 4 (x6)  -  Client - LocalScript:3
  12:48:39.515  Round 3 (x4)  -  Client - LocalScript:3
  12:48:40.501  Round 2 (x4)  -  Client - LocalScript:3
  12:48:41.701  Round 1 (x15)  -  Client - LocalScript:3
  12:48:45.916  Round 1  -  Client - LocalScript:3
  12:48:46.203  Intermission 0 (x6)  -  Client - LocalScript:3
  12:48:47.052  red team  -  Server - RoundsSystem:32
  12:48:47.223  Intermission 0  -  Client - LocalScript:3
  12:48:47.440  Round 0 (x12)  -  Client - LocalScript:3
  12:48:50.178  Intermission 0 (x8)  -  Client
  12:48:51.015  red team  -  Server - RoundsSystem:32

this round system isnt on a local script* the printing is the only thing in local script

I’m not too sure what the problem is now. But I’m somewhere on the line of the Intermission Time now staying on 0?

And if that’s so, have you tried setting the Intermission Time back to it’s original Time after the round has finished?

Like there perhaps? So it’d would look something like this :

if roundTime <= 0 then
    interTime = OriginalTime
end

Also one other thing I noticed looking back at your script. I don’t think it’d be a hot idea to have the i,v in pair loop.

If you wanted to check how many players there were, just a simple

#game.Players:GetPlayers()

Should do. Since you don’t need that specific loop for anything else besides checking if the minimum number of players meets the requirement. Otherwise, this is just my assumption, it might end up repeating the same thing over and over again the however many players are in the game.

thanks it works great now!

i just noticed a bug just now where when the game is still going on and if the player dies the player goes back to lobby but i dont want that to happen as i want it to respawn back in the map how would i do that

local status = game:GetService("ReplicatedStorage"):FindFirstChild("Status")
local maps = game.Workspace.Maps:GetChildren()
local interTime = 10 --Intermission Time
local roundTime = 420
local PlayerNeeded = 1
while true do wait()
	if #game:GetService("Players"):GetPlayers() >= PlayerNeeded then
		local formerroundtime = roundTime
		local formerintertime = interTime
		while true do --intermission loop
			status.Value = "Intermission:"..interTime
			if interTime > 0 then
				interTime = interTime - 1
			end
			wait(1)

			if interTime <= 0 then
				interTime = formerintertime
				break
			end
		end
		wait()
		status.Value = "Round Starting.."
		wait(3)
		local chosenMapNumber = math.random(1,#maps)--picks a random map
		local chosenMap = maps[chosenMapNumber]
		local TpRed = chosenMap.Spawns.RedSpawns:GetChildren()
		local TpBlue = chosenMap.Spawns.BlueSpawns:GetChildren()

		for i, player in pairs(game.Players:GetChildren()) do
			local char = player.Character
			if player.TeamColor == BrickColor.new("Really red") then
				print("red team")
				local tool = game.ServerStorage.Tools:GetChildren()
				local random = tool[math.random(1,#tool)]
				local cloned = random:Clone()
				cloned.Parent = player.Backpack
				char:WaitForChild("Humanoid"):EquipTool(cloned)
				char.HumanoidRootPart.CFrame =  TpRed[math.random(1,#TpRed)].CFrame * CFrame.new(0,3,0)
			elseif player.TeamColor == BrickColor.new("Really blue") then
				print("blue team")
				local tool = game.ServerStorage.Tools:GetChildren()
				local random = tool[math.random(1,#tool)]
				local cloned = random:Clone()
				cloned.Parent = player.Backpack
				char:WaitForChild("Humanoid"):EquipTool(cloned)
				char.HumanoidRootPart.CFrame =  TpBlue[math.random(1,#TpBlue)].CFrame * CFrame.new(0,3,0)
			end
		end

		while true do --round loop
			status.Value = "Game:"..roundTime

			roundTime = roundTime - 1

			wait(1)

			if roundTime <= 0 then
				roundTime = formerroundtime
				break
			end
		end
		for i, player in pairs(game.Players:GetChildren()) do
			player.Character:WaitForChild("Humanoid"):UnequipTools()
			player.Backpack:FindFirstChildOfClass("Tool"):Destroy()
			if player.Character:FindFirstChildOfClass("Tool") then
				player.Character:FindFirstChildOfClass("Tool"):Destroy()
			end
		end
		wait()
		status.Value = "Round Ended!"
		wait(3)
		for i, player in pairs(game.Players:GetChildren()) do
			player.leaderstats.Cash.Value += 70
			player:LoadCharacter()
		end
	else
		print("not enough!")
	end
end

Check to see if the Lobby Spawns are set as “Neutral” spawns. And also check to make sure the spawns in the game are set correctly with the Team Color.