Hello everyone! I am making a game where each round there is a random obby map, and now I am trying to do something more complex in my script. I want to have “tournaments” with many rounds, and I wanted to make the game start when there are 3 players or more. In my game there are 3 teams: Completed Spectators and Contestants.
So I wanted the first round to teleport all the spectators to the map, and then in the next rounds, teleport the players who are alive, that means, the ones that are in Completed team during intermission.
So basically, my script had a while true do loop, where it would make an intermission, teleport players to map, then teleport to lobby and destroy map… Regardless of the player’s team, it was teleporting everyone.
Now i changed the beginning of the loop to start only when there is more than 1 player (line 24)
Did I type something wrong in line 24? Or do I have to invert lines 23 and 24? I have no idea why its not working… Or maybe did I reference the number of players in a way that the script didn’t understand?
Why not test within studio using Multi client simulation? https://developer.roblox.com/en-us/articles/game-testing. Seems pretty inefficient to publish the game, then join the server with an alt account without access to studio.
You can easily click on that error within output and trace back your errors on what caused it at line 24.
Otherwise the error is caused by something inside the while true do loop. I believe a quick fix will be to insert a wait(1) before the if statements because without that then if there is only 1 player the while true do loop will run forever.
like
while true do
wait(1)
if #Players:GetPlayers()>1 then
end
--no yielding if condition is not met therefore while loop will loop way too fast
end
Next time use ``` to format your code so it’s easier for us to see and help, images are the worst.
Your script will timeout if the condition is not met (false or nil).
You’ll need to add a wait() in case that statement is not true (if #Players:GetPlayers()>1).