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

How would I check if a certain group is a user's primary group?

Asked by 8 years ago

If I already set up the script (this is for a database)

function GS.getPrimary(name)
    local proxy = "http://rproxy.pw"
    local url = proxy.."Groups/GetPrimaryGroupInfo.ashx?users="
    local request = url..name
    local result = GS.getContent(hs:GetAsync(request, true))
    return result
end

how can I link it to the player? I have something like this...

self.primary = gs.getPrimary(name)

The above code follows this format (for an example)

function GS.getImage(name)
    local proxy = "http://rproxy.pw"
    return "http://www.roblox.com/Thumbs/Avatar.ashx?username="..name
end

self.link = gs.getImage(name)

Thanks in advance!

1 answer

Log in to vote
0
Answered by 8 years ago

First off, you are concatenating the string incorrect as you are forgetting to insert a / between the .pw and Groups. Secondly, I have no clue what your getContent function exactly does so I will rewrite a working example of how to get a users primary group:

local http = game:GetService("HttpService")
function getUserPrimaryGroup(name)
    local response = http:GetAsync(string.gsub(string.format("http://www.roblox.com/Groups/GetPrimaryGroupInfo.ashx?users=%s",name),"roblox.com","rproxy.pw"),false)
    return response:match([["GroupName" : "(.-)"]])
end

print(getUserPrimaryGroup("DigitalVeer"))

You were on the right track; however, you need to put in the URL correctly and you can use string matching from the result to get the group name.

Ad

Answer this question