Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Roblox Live Member Group count not working?

Asked by 4 years ago
Edited 4 years ago

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.

0
What is Roproxy.com, isn't it roblox.com CaptainGalexyCreeper 15 — 4y
0
You can not access Roblox directly through HttpService Warriorfoox 25 — 4y
0
Why are you using WaitForChild to get a service? You never need to wait for services. User#24403 69 — 4y
0
Because I did, but that is not affecting the script. Warriorfoox 25 — 4y
View all comments (16 more)
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. User#24403 69 — 4y
0
Now it logs this error: Workspace.Part.SurfaceGui.Script:5: attempt to index a nil value Warriorfoox 25 — 4y
0
Are you sure this is the full code? Line 5 doesn't look like it has errors. User#24403 69 — 4y
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. Warriorfoox 25 — 4y
0
Could you edit your question with the current code you have now? User#24403 69 — 4y
0
Yes I just did. Warriorfoox 25 — 4y
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. User#24403 69 — 4y
0
I just looked at it like five minutes ago, there's nothing different. Warriorfoox 25 — 4y
0
[[<div id="MemberCount">Members: %d+</div>]]. 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 pidgey 548 — 4y
0
I do not understand your comment pidgey. incapaxx never mentioned anything about groups, nor do I understand what you mean by groups. Warriorfoox 25 — 4y
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) pidgey 548 — 4y
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. pidgey 548 — 4y
0
Do I have to escape the quotes too because now MemberCount is undefined Warriorfoox 25 — 4y
0
Yes escape the quotations too. pidgey 548 — 4y
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. Warriorfoox 25 — 4y
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 pidgey 548 — 4y

Answer this question