How would I get the amount of players in a place within a game?

I develop a game where it has many different places within the game that you teleport to, and on the menu of the game, I want to list the number of players in each place.

I am not sure how I would perform this, as I don’t know a function or anything I could use to get the player amount in the specific place within the game. I heard about proxies, but I don’t know how I would use them

If anyone knows a good solution, a reply would be appreciated

3 Likes

You could add a player counter where everytime a player join a place it adds 1 and when a player leaves, it substracts 1. You then make a gui that displays that counter.

3 Likes

I suggest using https://games.roblox.com/docs#!/Games/get_v1_games_placeId_servers_serverType (the /v1/games/{placeId}/servers/{serverType} part) basically you can use a proxy like https://rprxy.xyz/ or your own and send a request to this API for a specific place and server type
this API returns a table with each server and the amount of players it has(and other useful info like max players)
but before using this method I suggest watching some tutorials about Roblox Http requests and how they work.

4 Likes

But how would you track if someone leaves one of the places

Try this:
Once the player enters the game a BooleanValue enters his body.
Make a giant invisible cube of the area they need to be in.
If they touch the invisible cube the Value is set to true.
You add a thin invisible zone right the big cube on all directions and and when they touch that part their Value is set to false.

You could just see how many players are in a place by having a loop, and getting a table of the players, and use #table.

Then you could use messaging service to send it to the main game.
Or are you talking about a single place? Like areas?

Ok i should rephrase this, I mean the game within a universe, like a place you teleport to between games

this thread was moreso a question of getting the amount of players in all servers of a place

I remember making something very similar to this, here are very simplified steps on how I remember doing it:

-Using subscribeAsync and publishAsync
-Every 10 - 30 seconds send a new 'request' which basically asks each server for the amount of players (you can easily make it only count in a specific place instead of every place)
-Since each request has a different 'id' it never duplicates
-Add them all together, and voila