Hello developers,
I am trying to make a game which requires the game to get the current number of visits, though I am unable to do that as:
- I do not know how to use HTTP Service
- I don’t know anything about decoding or anything.
I have tried to use some scripts on devforum and then got that error, “Can’t parse JSON”, then I tried a second script which also did not work.
Script:
local http = game:GetService("HttpService") --obtaining the service for GETting
local placeId = game.GameId --your placeId
--since the game's API needs a universeId oddly, we can get it by:
local universeId = http:GetAsync("http://api.rprxy.xyz/universes/get-universe-containing-place?placeid="..placeId)
--hence it returns with a string, we can turn it into numbers (removing text), in a string, by:
universeId = universeId:gsub("[^%d%.%-]", "") --can be applied onto anything
--now, it's time to get the place's data after all that complicity
local get = http:GetAsync("http://games.rprxy.xyz/v1/games?universeIds="..universeId)
--turn it into a table
local data = http:JSONDecode(get)
--now we can get data from tables.
print(data["data"][1].visits) --basically made as: data = {["data"] = {visits = 0, other values}}
That is the code, I do not know what anything there does so yeah, thanks a lot if anyone is able to help!
(Expect me to respond like only in 16 hours, it is quite late…)