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:
01 | --Timers |
02 | local r = 25 --Before match |
03 | local g = 420 --During Match |
04 | local b = 600 --During Boss |
05 | local c = 15 --Waiting for players |
06 | local t |
07 | local team = game.Teams.Fighting:GetChildren() |
08 | local teamc = #team |
09 | --Variables |
10 | local players = game.Players:GetPlayers() |
11 |
12 | --Code Start |
13 | local function init () |
14 | t = tick() |
15 | end |
Thanks for looking!
The problem is you're setting the number of players upon the server's creation and then never changing it in the loop. So when the first player joins, #players will always remain 1 forever because it isn't being updated. To fix this, simply include it in the loop. To help you out, I'm also going to take out the obsolete stuff, but feel free to add it back if desired.
01 | --// Settings //-- |
02 |
03 | local r = 25 ; --Before match |
04 | local g = 420 ; --During Match |
05 | local b = 600 ; --During Boss |
06 | local c = 15 ; --Waiting for players |
07 |
08 | --// Main Loop //-- |
09 |
10 | while true do |
11 |
12 | local team = game.Teams.Fighting:GetChildren(); |
13 | local teamc = #team; |
14 |
15 | local players = game.Players:GetPlayers(); |
You are getting the amount of players only once, when the script first runs. So players will always be a table of one value - the first player who joined the server.
You need to GetPlayers() at the start of every loop:
01 | --Timers |
02 | local r = 25 --Before match |
03 | local g = 420 --During Match |
04 | local b = 600 --During Boss |
05 | local c = 15 --Waiting for players |
06 | local t |
07 | local team = game.Teams.Fighting:GetChildren() |
08 | local teamc = #team |
09 |
10 |
11 | --Code Start |
12 | local function init () |
13 | t = tick() |
14 | end |
15 |