How to find concurrent players of a SPECIFIC PLACE (NOT UNIVERSE, NOT GAME)

I’m assuming that you’re using teleportservice for the different places, and if that’s the case then just use fetch the active players of those places. Summary: Make different games for different modes and fetch the active players throughout the different modes.

2 Likes

I

Is there a proxy I can use for this link? The data in it works very well

2 Likes

fetching the active players of those places is what I’m trying to find out how to do

1 Like

Sorry, the only proxy I know is roproxy which gets blocked from that link anyway. I don’t know a proxy that works for that endpoint.

3 Likes

HttpService is exactly what you’re looking for if that’s the case. I highly recommend to watch videos about HttpService to get a better understanding. (Read this doc aswell)

HttpService | Documentation - Roblox Creator Hub

1 Like

I know how to use https service. I need the url that gives me the place concurrent users

1 Like

Just like koip said use:

"https://games.roblox.com/v1/games/PLACE_ID/servers/Public?sortOrder=Asc&limit=100"

here is what I got when I used it on one of my test games: games.roblox.com/v1/games/128863917312530/servers/Public?sortOrder=Asc&limit=100
image

From here just display the “playing” onto a gui.

1 Like

Update: I found an external website that keeps track of roblox data because this previous one isn’t allowed to be requested on.

RoProxy.com - A free, rotating proxy for Roblox APIs - Resources / Community Resources - Developer Forum | Roblox (use this instead to request for data)

Last update: You cannot request roblox game data with external servers unless you make your own website to track the data of your game with the help of GCP or AWS.

1 Like

Assuming the code runs from within the game itself, you can use MessagingService:

local MessagingService = game:GetService("MessagingService")

local function getServerPlayers(): number
	return #game.Players:GetPlayers() 
end

--Only bind this once
MessagingService:SubscribeAsync("GetPlayers", function(message)
	local data = message.Data
	if data[2] == game.JobId then return end
	if data[1] ~= game.PlaceId then return end
	MessagingService:PublishAsync("ReceivePlayers", getServerPlayers(), data[3])
end)

local function getPlayersOfPlace(placeId: number, waitTime: number?): number 
	local players = 0
	local guid = game.HttpService:GenerateGUID(false)
	local connection: RBXScriptConnection
	connection = MessagingService:SubscribeAsync("ReceivePlayers", function(message)
		local data = message.Data
		if data[2] ~= guid then return end --the just in case check
		players += data[1]
	end)
	MessagingService:PublishAsync("GetPlayers", placeId, game.JobId, guid)
	task.wait(waitTime or 5) --default delay is 5 seconds
	connection:Disconnect()
	return players+getServerPlayers()
end

local targetPlaceId = 0 --replace with your place id
local concurrent = getPlayersOfPlace(targetPlaceId) --this yields/has delay
print(concurrent)

Basically what’s happening above is that a server(for example your game lobby) asks all the other servers currently running for their current in-game players, and if the place id happens to match, they’re added in the total. In the example above we give 5 seconds to all the pinged servers to send back a response. If you want quicker refreshing times you can try decreasing the delay, although for this you don’t really need anything less than 2 seconds.

1 Like

If you read my post above, I already said all of this. You can request data on your own game, you just need a different proxy that supports it.

1 Like

While MessagingService does provide a good method, there is the off-chance that SubscribeAsync can fail, as shown on the documentation. So, a server could be missed out, undetected.

for anyone wondering, I didn’t only say SubscribeAsync could fail because it ends in Async. That’s not why…

2 Likes

They can add pcalls and retry logic on top of this so this wont happen. I usually avoid adding pcalls in my responses so I don’t overcomplicate them, except the very obvious cases, for example datastores.

Additionally if they know in advance which place ids they care for(within that universe), they can only subscribe the game servers that are in any of those place ids. So if for example they don’t care about knowing how many concurrent players the lobby place has, they can not subscribe the GetPlayers topic for the lobby servers(since we know in advance they wont be pinged). Lastly if you want to reduce traffic even more, you can add the place ids in the topics themselves(assuming they aren’t a lot, for example more than 100). That way if you do something like GetPlayers-{placeId} it will only ask the servers of placeId and thus reduce traffic(because only those servers will have subscribed to that event).

2 Likes

Yeah, they can add pcalls, but there’s still that tiny, incredibly unlikely but still existent chance of a fail. I would presume a separate place would have been used for the lobby instead of game servers under the same place, but if not, MessagingService would be better, yes. As for adding place IDs, the OP asked how to retrieve the CCU for one place, not many. For many place IDs, maybe even something like a memory store could work. Or, Roblox could just update the multiget-place-details endpoint… sigh…

2 Likes

If the error chance for this specific problem is really small, why bother? It’s not a datastore entry that will be impacted, just the numbers being very slightly off once in a while. I can just use the Ostrich Algorithm and call it a day.

I derived that they may need it for many due to the image they shared, it shows two images/game modes, so I assumed they may be under different places.

1 Like

My point is that there’s much less room for error with a proxy and the Roblox API. You’ve got the chance of an error from HttpService, a chance of an error from the proxy’s HTTP request, and the chance of an error from the proxy returning the data back to the HttpService. Where as with MessagingService, you’ve got the chance of an error from broadcasting the message, and each server has a chance of an error publishing the message back. Not to mention there will be a lot more traffic through the MessagingService despite the optimisation tactics you mentioned before. Adding more for other places, the chances of error are still much less using 2 HTTP requests.

2 Likes

Debatable. I doubt the Roblox metric on the website updates as frequently and as precisely as directly contacting the servers and asking them for it.

Although an update on the external APIs is needed in case someone wants this for places they can’t manage.

2 Likes

Roproxy doesnt work for this url if you try it

Correct, I missread your comment.

I had to index a few things with [“Data”] but this works, thank you!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.