Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

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

11 comments

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

0

No problem. Accept my answer if it helped you.

0

Sorry New to this, How do I do that?

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

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.

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.

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

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

0

The if #players = 5 line comes up with red lines underneath it

0

Edited. = is used for assignment and == is used for comparison.

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

You can do something very simple, like:

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

This discussion is preserved as it was. New answers, comments, and votes are closed.