Help with tables & using APIs for group member count

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. :heart:

:scroll: 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

:scroll: 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

:camera_flash: Errors (2):

Thanks again for any help. :thumbsup:

I got this from here. Later, they said they forgot to decode it but I’m not sure how to as I’m quite new to this kind of scripting.

Fixing decode:

Question:
Did you ever set up that link for the proxy?

Thanks for that, I’ll try it out. And yes, I did. Screenshot is below.

Did you set up the variable that has ‘LINKHERE’? Other than the encode I don’t see much wrong with this.

edit: I just realized they’re decoding it already?? try this:

Members = HttpProxy:GetAsync("https://groups.roblox.com/v1/groups/"..groupId).memberCount

Thanks, however I’m surprisingly still getting an error.

Script:

local HttpProxy = require(game.ServerScriptService.HttpProxyService:Clone())
GroupId = 7331168
Members = HttpProxy:GetAsync("https://groups.roblox.com/v1/groups/"..GroupId).memberCount
print(Members)
while wait(10) do
	local success, err = pcall(function()
		GroupId = 7331168
		Members = HttpProxy:GetAsync("https://groups.roblox.com/v1/groups/"..GroupId).memberCount
		print(Members)
	end)
	if not success then
		warn("[ERROR] " .. err)
	end
end