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

how can i get the all the players currently playing in my game?

im trying to print the current ammount of players currently playing in the game in total, i found a little script but i dont know how to fully make it work:

local body = game:GetService("HttpService"):JSONDecode(res) --res would be the response from the server

local playerCount = body.data[1].playing
print(playerCount)

also i get an error Argument 1 missing or nil at Line: 1. please help me!

1 answer

The Players service has a method called :GetPlayers() which returns all the players in an array. You can get the amount of indices in an array by using #.

print(#game:GetService("Players"):GetPlayers())

1 comment

0

but does it get them all in the whole game? aka the people that are playing?

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