Anyone can help please? Im trying to do game.Players.NumPlayers > 2 do print("There are enough players") else print("Need more players")
pls help
Anyone can help please? Im trying to do game.Players.NumPlayers > 2 do print("There are enough players") else print("Need more players")
pls help
Just created a table with game.Players:GetPlayers() then compared the value of #allPlrs with 2
local allPlrs = game.Players:GetPlayers()
if #allPlrs > 2 then
print("There are enough players")
else
print("Need more players")
end
I'm not the best with explaining anything, but hope this helps you understand a bit.
NumPlayers is deprecated. Here's what you can do instead
local Players = game:GetService("Players")
local PlayerCount = 0
Players.PlayerAdded:Connect(function()
PlayerCount = PlayerCount + 1
end)
Players.PlayerRemoving:Connect(function()
PlayerCount =PlayerCount - 1
end)
while PlayerCount < 1 do
print("Not enough players.")
repeat wait(1) until PlayerCount > 1
end
print("Enough players.")
Line 14 is completely pointless.
This discussion is preserved as it was. New answers, comments, and votes are closed.
3 comments
No, you should be using :GetPlayers()
Thank you, I've changed it
Good but on line 4, since he wants 2 players or more, so >= instead of just >, doing just this means the number has to be 3 or higher to start the game.