Hello, I need to get the amount of players in a game through the api, whenever I try to get it to return !
the amount of players in a game it returns “nil”
This is the code I used, but whenever I try to add something to “.body”, for example: “body.data” it will return nil. (It returns all the normal things without anything extra added to “.body”)
Any help is appreciated.
local httpService = game:GetService("HttpService")
local ProxyService = require(script.Parent.ProxyService)
local Proxy = ProxyService:New('example.com', 'example')
print(Proxy:Get('https://games.roblox.com/v1/games?universeIds=1686885941').body)
I can’t remember whether .data is automatically passed as .body but it should look something like this:
local decodedBody = httpService:JSONDecode(proxy:Get('https://games.roblox.com/v1/games?universeIds=100').body)
local active = decodedBody.data[1].playing
Im not sure if im explaining this right, but when you add “print(decodedBody.data)” it returns a bunch of other things like the games description, max server size, and a bunch of other things
There isn’t an API endpoint that specifically returns the amount of players in-game, you have to use the /games/ endpoint to get the amount of players in all servers.
I’m confused. You said to use #players:GetPlayers() or to use rprxy.deta.dev, both of which aren’t going to give the op what they want since there is no service that allows people to get the amount of players in all servers.
#players:GetPlayers() returns the amount of players in one specific server; the server in which the code is ran.