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

How to wait until three or more players are in a server?

Asked by 10 years ago

Just part of a script I am working on I have currently got local players = game.Players:GetPlayers()

To save the amount of players as a variable called players, how do I get it to wait until players is greater than or equal to 3. Thanks for the help in advance, Dstructiod

2 answers

Log in to vote
2
Answered by 10 years ago

Just use the NumPlayers property in the Players service.

repeat wait() until game.Players.NumPlayers >= 3

Or if you want to go the way you're going, do this:

repeat wait() until #players >= 3

For your GUI problem, try this (make sure this is in a Script and not a LocalScript):

if #players == 5 then 
    for i = 1,#players do
        local gui = game.ServerStorage.MF:Clone() --Clones the gui
        gui.Parent = players[i]:WaitForChild("PlayerGui") --In case PlayerGui doesn't exist yet.
    end
end
0
THANKS YOUR'E THE BEST, If I encounter any other thing I need help with, I will just post again but Great and Thanks Dstructiod 0 — 10y
0
No problem. Accept my answer if it helped you. Spongocardo 1991 — 10y
0
Sorry New to this, How do I do that? Dstructiod 0 — 10y
0
Also, How would I get it to show a GUI to all players from the server storage? I have the function set up just need to know how to move it Dstructiod 0 — 10y
View all comments (7 more)
0
To accept my answer, look to the right of these comments and there should be a button saying "Accept this answer". Click that. For the GUI, I'll edit my post to show you how. Spongocardo 1991 — 10y
0
Use the Clone() method and put that clone in a player's player gui. Also you'll find an accept answer button on the right. Perci1 4988 — 10y
0
All there is tot he right is an up or down arrow under that and Answered By (You) under that 25 minutes ago under that Edited 20 mins ago and under that it says reoprt Dstructiod 0 — 10y
0
I don't want a GUI to show how many players are needed, I have made a GUI and I want it to show up on players' screen when there are a specific amount of players in the game so far I have if #players = 5 then game.ServerStorage.MF:Clone(game.Players#players.PlayerGUI) end But I think thats is wrong Dstructiod 0 — 10y
0
The if #players = 5 line comes up with red lines underneath it Dstructiod 0 — 10y
0
Edited. = is used for assignment and == is used for comparison. Spongocardo 1991 — 10y
0
Hey listen, I'm making a game for the GCC had the idea for it and built it but scripting is not my string point is there any way you would like to get in on the game with me as a developer team? If so I can send you what needs to be done scripting wise Dstructiod 0 — 10y
Ad
Log in to vote
0
Answered by
Relatch 550 Moderation Voter
10 years ago

You can do something very simple, like:

if #game.Players:GetPlayers() > 3 then --Gets Players and checks if 3 are there
    --text
else
end

Answer this question