Group Member Count Not Showing Up

I’m trying to get group info in Roblox, but the member count isn’t coming through “Owner User Is working”. Here’s the script I’m using:

groupInfoRequest.OnServerEvent:Connect(function(Player, groupID)
	print("Received request for group ID:", groupID)

	local groupInfo = game:GetService("GroupService"):GetGroupInfoAsync(groupID)

	if groupInfo then
		local memberCount = groupInfo.MemberCount or "N/A"
		local groupData = {
			Owner = groupInfo.Owner.Name,
			MemberCount = memberCount
		}
		groupInfoRequest:FireClient(Player, true, groupData)
		print("Group Data:", groupData.Owner, groupData.MemberCount)
	else
		print("Failed to retrieve group info.")
		groupInfoRequest:FireClient(Player, false, nil)
	end
end)

Can anyone help me figure out why the member count isn’t showing up?

I am looking at the documentation for GroupService and I am not seeing anything in the table here that would lead me to believe that groupInfo.MemberCount is a method that exists. It seems that you are trying to reference something which is not part of the table returned by calling :GetGroupInfoAsync().

Check out these threads for more information on how you can get this information using HttpService!

There is a roblox API that holds detailed information about groups like the member count. So we will need to access it using HTTP service

local HttpService = game:GetService("HttpService")
groupInfoRequest.OnServerEvent:Connect(function(Player, groupID)
	print("Received request for group ID:", groupID)
    local url = "https://groups.roblox.com/v1/groups/" .. groupID   
    local membercount     
    local success, response = pcall(function()
        return HttpService:GetAsync(url)
    end)
    if success then
        local data = HttpService:JSONDecode(response)
        membercount = data.memberCount
    else
        warn("Failed to get group information.")
    end
end)
if memberCount then
    print("The group has " .. memberCount .. " members.")
else
    print("Failed to retrieve the member count.")
end

hey i tried using http but warn says this “HttpService is not allowed to access ROBLOX resources”

Hello! I am the OP of the second resource you linked! Thank you for making me aware that this was still posted, I have updated the comment to reflect it no longer works and update some old bad coding practices. The code itself works fine, but the proxy no longer exists. There’s a lot of other proxies @kvautme could use and could just drop in as a replacement to the one I used 4 years ago.

Still waiting for Roblox to just have an official API usable in-game.

You could probably use this exact same code and just replace the url part with this:

local url = "https://groups.roproxy.com/v1/groups/" .. groupId -- use a proxy due to Roblox not allowing requests.

Damn I forgot how you cannot access the Roblox website like that :man_facepalming:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.