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
That might be the problem. In terms of Logic if the Intermission Time is greater orequal to 0, then subtract 1. However, you are checking to see if the Intermission Time is exactly 0 to break.
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
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.
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.