I’m working on a Capture the Flag game mode, but I’m running into a problem where the round system keeps going into Intermission repeatedly without starting the actual game
What I’m Trying to Achieve:
Players click Play to join the game
After a 10 second intermission, the round should start
My Issue?
After the intermission, instead of starting the round, it just goes back to another intermission (intermission > intermission > intermission >…)
no errors are in the output
What I’ve Checked So Far:
intermissionSpawn and gameSpawn are correctly placed in the workspace
Flag exists in the workspace.
Part of my script:
here’s a simplified version of the core script:
while true do
if #activePlayers > 0 then
local selectedGamemode = { Name = "Capture the Flag" }
teleportActivePlayers(intermissionSpawn)
startCountdown("Intermission", INTERMISSION_TIME, selectedGamemode)
teleportActivePlayers(gameSpawn)
startCountdownUI()
startCaptureTheFlag()
RoundStatusEvent:FireAllClients("RoundEnded", 0, selectedGamemode.Name)
else
print("Waiting for players to press Play.")
RoundStatusEvent:FireAllClients("Intermission", INTERMISSION_TIME, "Waiting for players")
task.wait(5)
end
end
I’d also add a check for if a round is active, only because i have a feeling you’re only removing activePlayers once the round ends, again, i don’t know whats going on in the rest of your code so i can’t be sure.
local isRoundActive = false
while true do
if #activePlayers > 0 then
if isRoundActive ~= true then
isRoundActive = true
-- Rest of your code
-- Make sure to set isRoundActive to false once the round ends
end
else
-- Rest of your code
end
end
Are your prints showing in the Output window? If not you have to troubleshoot your code.
Instead of waiting for prints after if checks you should print the variables being used them. If the variable isn’t what you’d expect then you know where to look for the issue.
print("#activePlayers = ", #activePlayers)
if #activePlayers > 0 then
-- rest of code
Thanks for the suggestion! I see what you mean about adding an isRoundActive check to prevent overlapping rounds. That makes a lot of sense, especially since I wasn’t using anything like that before. I’ll try adding it and see if it fixes the intermission loop.
Also, players are being teleported after the countdown, but the round just doesn’t seem to start. I’ll double-check the functions like startCaptureTheFlag() and teleportActivePlayers() to make sure everything is working as expected.
I’ll report back once I test it. Appreciate the help!