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

must have 3 players to start server?

anyone know how to do this??

1 comment

0

start gamemode

2 answers

local players = game:GetService("Players")

players.PlayerAdded:connect(function(player)
	if players.NumPlayers >= 3 then 
		--This is where you can start your game
	end
end)

5 comments

0

what does #players mean?

0

You could do that in a much more simple way. I'll post an answer.

0

#players can be read as "number of players". Keep in mind this code does not account for if the game is already started or not. This could also be accomplished using a "repeat" loop

0

Updated code to use NumPlayers instead

0

Glad my answer help update your answer. :)

Hope this helps. :)

if game.Players.NumPlayers >= 3 then -- If game.Players.NumPlayers is more than or equal to then
print("Enough players!") -- output
-- Add your additional code here
else -- If there isn't, then
print("Not enough players!") -- output
end

2 comments

0

This won't work, the script will start when the game instance is created and print "Not enough players" and do nothing more. Using NumPlayers is probably smarter though, I've updated my code.

0

Have you tested it with 3 players in the server?

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