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

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

Asked by 6 years ago

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.

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 abnotaddable 920 — 6y
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) abnotaddable 920 — 6y
0
local players = game:GetService("Players"):GetChildren() print(#players) abnotaddable 920 — 6y

2 answers

Log in to vote
0
Answered by 6 years ago

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!

Ad
Log in to vote
0
Answered by 6 years ago

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)

Answer this question