Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

This Script Of Mine Isn't Functioning Properly?

Asked by 4 years ago
Edited 4 years ago

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

2 answers

Log in to vote
0
Answered by
Elixcore 1337 Moderation Voter
4 years ago
Edited 4 years ago

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.
Ad
Log in to vote
0
Answered by
imKlevi 94
4 years ago

Try this

local players = game:GetService("Players")

while wait() do
    if #players:GetPlayers() >= 6 then 
        print("Enough players!")
    else
        print("Not enough") 
    end
end
0
Please don't spoonfeed. DeceptiveCaster 3761 — 4y
0
Thanks Yours Worked Aswell User#29372 0 — 4y

Answer this question