local HttpProxy = require(game.Workspace.HttpProxyService:Clone()) -- Script that does all the stuff
local HttpService = game:GetService('HttpService')
function getUrl()
local cooldown = 2.5
local id = 1000
while true do
local DecodedJSON = (HttpService:JSONDecode(HttpProxy:GetAsync('http://api.roblox.com/users/'.. tostring(id)..'/onlinestatus')))
print(DecodedJSON)
script.Parent.Text = DecodedJSON[4]
id = id + 1
wait(cooldown)
end
end
getUrl()
Technically, roblox games aren’t supposed to be able to access roblox urls with the Http service, which I’m guessing the proxy is for. It is an error in the proxy, so we’d need to see that as well. (I can tell its a proxy error because the table is not printing like it should with print(DecodedJSON) (If you want to see the contents of the table, print the non JSONDecoded version, as printing a table just prints table: 0x(Hex Numbers) and this isn’t very helpful for debugging.)
local ScriptId = 'AKfycbzqPGyRZxrURwszw0P3NiTCTsI6sGmze6JkHpK_c1V7GQq_Fbw'
local Url = "https://script.google.com/macros/s/" .. ScriptId .. "/exec"
local HttpService = game:GetService('HttpService')
local Module = {}
function JSONDecode(JSON)
local JSONTable = {}
pcall(function ()
JSONTable = HttpService:JSONDecode(JSON)
end)
return JSONTable
end
function Module:GetAsync(Link)
local JSON = HttpService:GetAsync(Url .. "?q="..game.HttpService:UrlEncode(Link))
local Result = JSONDecode(JSON)
if Result.result == "success" then
return Result.response
else
warn(tostring(Link).." failed to fetch because "..tostring(Result.error))
return
end
end
return Module
Your issue is that the module already encodes the returned data to a table, so no need for the HttpService:JSONDecode(HttpProxy:GetAsync('http://api.roblox.com/users/'.. tostring(id)..'/onlinestatus')), all you need is HttpProxy:GetAsync('http://api.roblox.com/users/'.. tostring(id)..'/onlinestatus')
Subdivide things like this next time to debug faster:
local ReturnedData = HttpProxy:GetAsync('http://api.roblox.com/users/'.. tostring(id)..'/onlinestatus')
print(ReturnedData)
local DecodedJSON = (HttpService:JSONDecode(ReturnedData))
print(DecodedJSON)
It prints a table, and trying to decode a table creates the error.
local HttpProxy = require(game.Workspace.HttpProxyService:Clone()) -- Script that does all the stuff
local HttpService = game:GetService('HttpService')
function getUrl()
local id = 1000
local cd = 2.5
while true do
local ReturnedData = HttpProxy:GetAsync('http://api.roblox.com/users/'.. tostring(id)..'/onlinestatus')
print(ReturnedData)
local DecodedJSON = (HttpService:JSONDecode(ReturnedData))
print(DecodedJSON)
id = id + 1
wait(cd)
end end
getUrl()
local DecodedJSON = (HttpService:JSONDecode(ReturnedData)) You are still decoding the value, that is your error. the JSONDecode can only decode strings.
function getUrl()
local id = 1000
local cd = 2.5
while true do
local ReturnedData = HttpProxy:GetAsync('http://api.roblox.com/users/'.. tostring(id)..'/onlinestatus')
id = id + 1
wait(cd)
end end
Please read replies fully before replying or just copying code, reply #3 should have been enough if you had read it fully and not just copied the code that was there to show how to debug in small steps.