What I'm trying to do is to get the amount of visits in a game but whenever I try to do data.visits, it just returns nil but if I just put data by itself, it says everything. How would I exactly print only the visits?
local httpService = game:GetService("HttpService") local url = "https://games.rprxy.xyz/v1/games?universeIds=2471084" local res, data = pcall(function() return httpService:GetAsync(url, true) end) print(res, data.visits)
Output:
true nil
This returns a Encoded JSON Table, you need to decode it for use. And if you see, in Response have a table called "Data" in that table have another table that you need to open for get Information.
How to decode it?
httpService:JSONDecode(Response)
How access this?
DecodedJSON.data[1]
Example code:
local HttpService = game:GetService("HttpService") local Url = "https://games.rprxy.xyz/v1/games?universeIds=2471084" local Success, Response = pcall(function() return HttpService:GetAsync(Url) end) if Success then local Success, Response = pcall(function() return HttpService:JSONDecode(Response) end) if Success then local Information = Response.data[1] print("Game Visits:", Information.visits, "Max Players:", Information.maxPlayers) else print("Can't decode JSON Data") end else print("can't get data") end
Hope it helped! :)