Hello. I’m trying to use an API proxy I made following a tutorial to get the member count of my group in-game, however I’m encountering a few errors appearing in the Output panel when joining the game. If anyone could re-write my code so it works or tell me what I’m doing wrong and how to fix it, that’d be much appreciated! Code is below.
Server Script:
local HttpProxy = require(game.ServerScriptService.HttpProxyService:Clone())
GroupId = 7331168
Members = game.HttpService:JSONEncode(HttpProxy:GetAsync("https://groups.roblox.com/v1/groups/" .. tostring(GroupId))).memberCount
print(Members)
while wait(10) do
local success, err = pcall(function()
GroupId = 7331168
Members = game.HttpService:JSONEncode(HttpProxy:GetAsync("https://groups.roblox.com/v1/groups/" .. tostring(GroupId))).memberCount
print(Members)
end)
if not success then
warn("[ERROR] " .. err)
end
end
Module Script:
local ScriptId = "linkhere"
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
print(Result.response)
return Result.response
else
warn(tostring(Link).." failed to fetch because "..tostring(Result.error))
return
end
end
return Module
Errors (2):
Thanks again for any help.