Issue with getting my part to show how much members my group have

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I want it to show how many members my group have on my part
  2. What is the issue? Include screenshots / videos if possible!
    I’m trying to get my part to show how many members I have but my part is saying 0 members in That is not right I don’t know if I’m using Roblox Open Cloud right to get it to work hers my script

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local HttpService = game:GetService("HttpService")
local RunService = game:GetService("RunService")

local GROUP_ID = 7045894  -- Replace with your actual group ID
local API_KEY = ""  -- Replace with your actual API key
local startTime = os.time()

local function getGroupMemberCount()
	local url = "https://groups.roblox.com/v1/groups/" .. GROUP_ID
	local headers = {
		["Authorization"] = "Bearer " .. API_KEY
	}

	local success, response = pcall(function()
		return HttpService:GetAsync(url, true, headers)
	end)

	if success then
		local data = HttpService:JSONDecode(response)
		return data.memberCount or 0
	else
		warn("Failed to fetch group member count: " .. tostring(response))
		return 0
	end
end

local function updateServerStatsForPlayer(player)
	local surfaceGui = workspace.ServerStats.Server:FindFirstChild("SurfaceGui")
	if surfaceGui then
		local serverTimeLabel = surfaceGui:FindFirstChild("Frame"):FindFirstChild("Stats"):FindFirstChild("serverTime"):FindFirstChild("num")
		local playerCountLabel = surfaceGui:FindFirstChild("Frame"):FindFirstChild("Stats"):FindFirstChild("players"):FindFirstChild("num")
		local groupMemberLabel = surfaceGui:FindFirstChild("Frame"):FindFirstChild("Stats"):FindFirstChild("groupMembers"):FindFirstChild("num")

		local currentTime = os.time()
		local elapsedTime = currentTime - startTime
		local hours = math.floor(elapsedTime / 3600)
		local minutes = math.floor((elapsedTime % 3600) / 60)
		local seconds = elapsedTime % 60
		local serverTime = string.format("%02dh %02dm %02ds", hours, minutes, seconds)
		local playerCount = #Players:GetPlayers()
		local maxPlayer = 18
		local formattedPlayerCount = string.format("%d | %d", playerCount, maxPlayer)
		local groupMemberCount = getGroupMemberCount()

		serverTimeLabel.Text = serverTime
		playerCountLabel.Text = formattedPlayerCount
		groupMemberLabel.Text =  groupMemberCount
	end
end

local function updateServerStats()
	for _, player in pairs(Players:GetPlayers()) do
		updateServerStatsForPlayer(player)
	end
end

Players.PlayerAdded:Connect(function(player)
	updateServerStatsForPlayer(player)
end)

Players.PlayerRemoving:Connect(updateServerStats)

RunService.Stepped:Connect(function()
	updateServerStats()
	wait(1)
end)

This script will not work without an API Key. I’ve tried doing this too and searched for tutorials but they are now outdated.

I left the API key brink for the post because they say don’t give out your API key

So you’re using an app or website’s API key to obtain the group member amount? Because you may be talking about a security key which you shouldn’t give out.

It’s Roblox open cloud API key I’m trying to use open cloud to get how many members are in my group