I Am Working On A Script That Waits For A Certain Amount Of Players Before Teleporting The Players To A Certain location But I Don't Under Stand Why This Part Of The Script Inst Working Any Help Would Be Great
local players = game:GetService(“Players”) while wait() do if #players:GetPlayers() >6 then print(“Enough players!”) else print(“Not enough”) end end
You said 'waits for a certain amount of players'
So my take on doing this would be polling.
Using repeat can do what you're trying to do, but functions differently.
I personally see no reason in having a while loop for this sort of thing, so here is an example of repeat used.
repeat --[[code to repeat]] until --[[requirement to be met]]
the code will execute each time the requirement is not met. If the requirement is met then the script will stop executing along with the yielding.
This will cause the script to continue on.
repeat wait() until #game.Players:GetPlayers() >= 6 -- repeating wait() until requirement is met. print('Enough Players!') -- after requirement is met, print.
Try this
local players = game:GetService("Players") while wait() do if #players:GetPlayers() >= 6 then print("Enough players!") else print("Not enough") end end