Hello! I was making a global timer that sets off other events and I didn't get very far before seeing an error that didn't pop up in the output. Off the bat I know there are probably many errors in this, but one thing that stands out is the game can't tell how many players are in the game. It just keeps doing the loop and printing (Not enough players). I tested this on a server with 3 people, but it still doesn't work.
Here's the script:
- Server Script
- In ServerScriptService (Workspace doesn't change anything)
--Timers
local r = 25 --Before match
local g = 420 --During Match
local b = 600 --During Boss
local c = 15 --Waiting for players
local t
local team = game.Teams.Fighting:GetChildren()
local teamc = #team
--Variables
local players = game.Players:GetPlayers()
--Code Start
local function init ()
t = tick()
end
while true do
print("Intermission")
wait(r)
if #players >= 2 then
print("Match Started")
repeat
local curt = tick()
local match = t - curt
until match > g or teamc == 1
print("Match Ended")
else if #players < 2 then
print("Not Enough Players")
end
end
end
Thanks for looking!

2 comments
Thanks! It I was getting confused on why putting Player in the loop would help, but then I relized it gets the player amount every time the loop happens and replaces the old variable.
It doesn't replace the old variable because
playersonly exists within that scope. Once the loop repeats, it leaves that scope, removing it, and then you redefine it.