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

must have 3 players to start server?

Asked by 7 years ago

anyone know how to do this??

0
start gamemode lopehole12 0 — 7y

2 answers

Log in to vote
0
Answered by
Jellyfosh 125
7 years ago
Edited 7 years ago
1local players = game:GetService("Players")
2 
3players.PlayerAdded:connect(function(player)
4    if players.NumPlayers >= 3 then
5        --This is where you can start your game
6    end
7end)
0
what does #players mean? lopehole12 0 — 7y
0
You could do that in a much more simple way. I'll post an answer. StoleYourClothes 105 — 7y
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 Jellyfosh 125 — 7y
0
Updated code to use NumPlayers instead Jellyfosh 125 — 7y
0
Glad my answer help update your answer. :) StoleYourClothes 105 — 7y
Ad
Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

Hope this helps. :)

1if game.Players.NumPlayers >= 3 then -- If game.Players.NumPlayers is more than or equal to then
2print("Enough players!") -- output
3-- Add your additional code here
4else -- If there isn't, then
5print("Not enough players!") -- output
6end
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. Jellyfosh 125 — 7y
0
Have you tested it with 3 players in the server? StoleYourClothes 105 — 7y

Answer this question