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

A player number counter? Undefinable in Roblox WIki and no categories?

So I need a player counter that counts the players. I couldn't find a result online or in ROBLOX wiki.

What I'm trying to do is when a player joins a game it will keep looping an intro until another player joins.

But I can't use PlayerAdded so I need to a player counter. I know this is a script request (kinda) but I have no clue where to find any results other than here. I have looked everywhere necessary but now I will need the assistance of the fellow members on Scripting Helpers.

Thank you for any feed back or links to the feature I'm looking for.

3 comments

0

you could have a value in server storage and a script in serverscriptservice and everytime a player joins it adds one to the value and everytime a player leaves it takes away one

0

alternitively you could create a table like local PlayerTable = {} and loop through each player and insert them into the table and then do print(#PlayerTable)

0

local players = game:GetService("Players"):GetChildren() print(#players)

2 answers

✓ Accepted answer

You could just get all the children in Players, like abnotaddable did like so.

print(#game.Players:GetChildren())

What this does, is gets the children under the Player service. Then, it counts how many children are in the table, then it gets printed. Hope this helps!

You could use PlayerAdded and add one to a value, but this is inefficient with the introduction of tables and things.

local PlayerCount = game:GetService("Players"):GetPlayers()
print(#PlayerCount)

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