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

See how many players are in a place?

Asked by 9 years ago

Is it possible to see how many players are in a place/universe place with a script?

1 answer

Log in to vote
1
Answered by 9 years ago

You could find that out with two efficient ways:

local plrs_in_game = game.Players.NumPlayers

or

local plrs_in_game = #game.Players:GetPlayers()

Both of them will return the number of players in the server.

If you want to find out how many in a place, you would have to use datastores

game.Player.PlayerAdded:connect(function()
game:GetService("DataStoreService"):GetDataStore("Plrs"):IncrementAsync("Players",1)
end)

game.Player.PlayerRemoving:connect(function()
game:GetService("DataStoreService"):GetDataStore("Plrs"):IncrementAsync("Players",-1)
end)
Ad

Answer this question