Is there a way to show the amount of players in an another game?

Yes, through the Games API. The endpoint you’re looking for will be /v1/games; if the docs page defaults to Games Api v2, just hit the drop down and go to Games Api v1. You will see all v1 endpoints there, so find /v1/games and click it for more information.

Do be aware, you will require a proxy to query any Roblox endpoints from HttpService. rprxy.xyz is the most popular one in use right now. You simply need to replace any cases of roblox.com with rprxy.xyz and the proxy will handle the API interaction and response returning for you.

The parameter is universeIds, so you can attach that via ?universeIds=. You can query a maximum of 100 games which are separated by commas, e.g. ?universeIds=1,2,3. Universe ids will be the game ids you want to see the players of. You can find this in many different fashions. For your own places, you would hit Configure this game and look in the URL bar for the game id, then plug it in here.

The response body is a JSON table with data about the places you’ve queried. The initial layer is a dictionary with the sole key of data and in there are arrays containing information about your queried places. To use this in a table format, pass the result through JSONDecode then access the data key. From here, you can access the playing key of the data table for your place which will determine how many players are active across your queried game.

As far as code samples go, I can supply you one. It’s broken down so you can see the steps. This example queries the current game and returns the players active within it.

local HttpService = game:GetService("HttpService")

local QUERY_URL = "https://games.rprxy.xyz/v1/games?universeIds="
local GAME_ID = game.GameId

-- "https://games.rprxy.xyz/v1/games?universeIds=000000"
local endpointResponse = HttpService:GetAsync(QUERY_URL .. GAME_ID)
local decodedResponse = HttpService:JSONDecode(endpointResponse)
local gameData = decodedResponse.data

local gameInformation = gameData[1]
local playersInGame = gameInformation.playing

print(playersInGame) -- 0

No wizardry, no self-hosting. Just using some nice endpoints. :slightly_smiling_face:

cc @ChiefWildin

14 Likes