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

How do I use numplayers?

Well if I spelled that numplayers wrong then whatever but anyways how do I use it? Do you have to use a for loop or something? Cause this is what I think you can use but with a numplayer function:

for i = 1, 4 do
	m = Instance.new("Hint", Workspace)
	m.Text = "Waiting for 4 players to join."
end

If you know a better way to do this or without a for loop than please help me. THANKS!

1 answer

✓ Accepted answer

game.Players.NumPlayers --> Returns an integer

For example:

function PlayerEntered(player)
	repeat wait() until player.Character
	if game.Players.NumPlayers == 1 then -- If the number of players is 1
		-- only one person here in the server
	elseif game.Players.NumPlayers >= 2 then -- If the number of players is 2 or greater
		-- there is two or more players in the server
	end
end

game.Players.PlayerAdded:connect(PlayerEntered)

You can also look in the Roblox Wiki.

Web page for NumPlayers: http://wiki.roblox.com/index.php?title=NumPlayers

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