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

How can I count how many players there are?

Asked by
traigla 75
10 years ago

How can I count how many players are in the Players section of my game?

I have got all the children by doing game.Workspace.Players:getChildren

How do I count how many players there are?

Thanks! traigla

2 answers

Log in to vote
1
Answered by
TofuBytes 500 Moderation Voter
10 years ago

Please provide explanation with your answers. Simply posting code does not spread knowledge of integral scripting processes which helps people understand the logic and reasoning behind your answer.

Use game.Players:GetPlayers() to get the players. Then print the #players

local players = game.Players:GetPlayers()
print(#players)
0
How do I find how many there are though? traigla 75 — 10y
0
That will get the number of players. TofuBytes 500 — 10y
0
I've written: players = game.Players:getplayers() print(players) traigla 75 — 10y
0
I get 'nil' traigla 75 — 10y
View all comments (3 more)
0
local players = game.Players:GetPlayers() print(#players) TofuBytes 500 — 10y
0
Works. Thanks for your help! :-) traigla 75 — 10y
0
You're welcome. :) TofuBytes 500 — 10y
Ad
Log in to vote
-2
Answered by
RubenKan 3615 Moderation Voter Administrator Community Moderator
10 years ago

Please provide explanation with your answers. Simply posting code does not spread knowledge of integral scripting processes which helps people understand the logic and reasoning behind your answer.

Players = game.Players:GetChildren() print(#Players)

Answer this question