I've been recently trying to figure out how to make a live member group count in-game but it prints off the error

21:53:49.534 - Workspace.Part.SurfaceGui.Script:5: attempt to index a nil value
21:53:49.535 - Stack Begin
21:53:49.535 - Script 'Workspace.Part.SurfaceGui.Script', Line 5 - global getGroupSize
21:53:49.535 - Script 'Workspace.Part.SurfaceGui.Script', Line 11
21:53:49.535 - Stack End

I think this is due to the proxy just not existing anymore, but if I can get any help on this that would be helpful because I cannot find any other proxies that work with this. This is my code:

function getGroupSize(groupId)
    local groupLink = "http://www.roproxy.tk/My/Groups.aspx?gid=" .. groupId
    local html = game:GetService("HttpService"):GetAsync(groupLink, true)
    local pattern = [[<div id="MemberCount">Members: %d+</div>]]
    local size = tonumber(html:match(pattern):match("%d+"))
    return size
end

print(getGroupSize(3101776))

I am using the script from https://scriptinghelpers.org/questions/17476/is-there-a-function-that-can-return-the-number-of-members-a-group-has but I cannot get a working answer from that.

20 comments

0

What is Roproxy.com, isn't it roblox.com

0

You can not access Roblox directly through HttpService

0

Why are you using WaitForChild to get a service? You never need to wait for services.

0

Because I did, but that is not affecting the script.

0

Use GetService to get services, seriously. The issue though is you modified the code and messed it up. Just use the original code. It works perfectly fine. The issue is you never found a match of pattern in html, you instead tried finding a match of a digit (%d) in the entire html. and please dont use while wait() do. instead, use while true do. it's clearer.

0

Now it logs this error: Workspace.Part.SurfaceGui.Script:5: attempt to index a nil value

0

Are you sure this is the full code? Line 5 doesn't look like it has errors.

0

That's the code I put, for some stupid reason I can't figure this out and you already have. I don't see the issue on mine and I updated the code to the one I'm currently using.

0

Could you edit your question with the current code you have now?

0

Yes I just did.

0

It's possible that roblox updated their html for whatever reason. Try following the instructions on that answer to see if the html changed.

0

I just looked at it like five minutes ago, there's nothing different.

0

[[

Members: %d+
]]. matching this will return the entire result (because you don't have a group). Trying to match that again with "%d+" will return nil because %d+ is now a number. Use groups look at what incapaxx said

0

I do not understand your comment pidgey. incapaxx never mentioned anything about groups, nor do I understand what you mean by groups.

0

pattern = "<div id="MemberCount">Members: (%d+)</div>" OP match this and print it a line after to see if it matched correctly. If not the HTML may be incorrect. Also, make sure to escape the slash character (good common practice for regex)

0

OP: String captures (or groups) are used to get specific pieces of a string and save them to variables. You can capture almost anything — a single character class, multiple characters (class with a quantifier), or even character class sets. Captures are defined by parentheses () around them.

0

Do I have to escape the quotes too because now MemberCount is undefined

0

Yes escape the quotations too.

0

Can you just put this in an answer because 1. I'm confused and 2. If it's correct I can mark it as the right answer.

0

OP, as I said in my answer, 'http://www.roproxy.tk' is not getting the proper data you need. Roblox may have changed something to prevent scraping? I don't know. I don't actually know of any alternatives because I never do anything like this. I still recommend using capture groups. Good practice for Regex