I am not so experienced with HttpService- so I guess I need a little help heh.
Can someone answer with a script that will update the members even when one joins, like on a TextLabel for example.
And explain how it works since I need to know this.
You can GET this api to get the member count, and then print the memberCount value.
Here’s an example of a request using RequestAsync:
local HttpService = game:GetService("HttpService")
local response = HttpService:RequestAsync{
Url = "https://groups.roblox.com/v1/groups/"..groupId..
Method = "GET";
Headers = {
["Content-Type"] = "application/json";
};
}
if response.Success then
print("Status code: " .. response.StatusCode .. " " .. response.StatusMessage)
print(response.Body)
else
print("The request failed: " .. response.StatusCode .. " " .. response.StatusMessage)
end
@Shyfoox Apologies, I did not realize that ROBLOX does not allow access to API’s from in-game. If you want to use the API from in-game you need to use a proxy server, or set up your own server that handle’s GET requests and returns a response body.
If you are not able to set one up/get access to one take a look at this tutorial. I cannot however guarantee that it still works though.
This code was updated on 2024 to change proxies from rprxy.xyz to roproxy.com as RPRXY is no longer maintained and is shutdown. I will most likely never update this comment again, so please just make sure you’re checking to see which proxy to use here on the Devforum. Just search “roblox proxy” and find the most up-to-date Community Resource!
Alright for anyone else who looks at this thread. Yes it’s possible to get a live group member count.
This is how I did it.
local HTTP = = game:GetService("HttpService")
local groupId = "" -- the group you want to see the live member count for
local url = "https://groups.roproxy.com/v1/groups/" .. groupId -- use a proxy due to Roblox not allowing requests.
local success, response = pcall(HTTP.GetAsync, HTTP, url)
if not success then
error("Failed to fetch Group page!")
end
while true do
local success, response = pcall(HTTP.GetAsync, HTTP, url)
if not success then
continue
end
local data = HTTP:JSONDecode(response)
script.Parent.Text = data.name .. " Live Member Count:\n" .. data.memberCount
task.wait(5)
end
NOTE:
You will need to enable HttpService (Allow HTTP Requests) for this to work.
Also this is an example if it was part of a TextLabel. Of course this can be changed anyway you want it to be. Members does not return as a number and instead as a string as most HTTP responses will be. It can be coerced into a number inferred or with tonumber(response.memberCount)
.
Example usage
I hope this helps!
it works good and thank you for it