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 6 years ago

anyone know how to do this??

0
start gamemode lopehole12 0 — 6y

2 answers

Log in to vote
0
Answered by
Jellyfosh 125
6 years ago
Edited 6 years ago
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)
0
what does #players mean? lopehole12 0 — 6y
0
You could do that in a much more simple way. I'll post an answer. StoleYourClothes 105 — 6y
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 — 6y
0
Updated code to use NumPlayers instead Jellyfosh 125 — 6y
0
Glad my answer help update your answer. :) StoleYourClothes 105 — 6y
Ad
Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

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
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 — 6y
0
Have you tested it with 3 players in the server? StoleYourClothes 105 — 6y

Answer this question