I think I figured out how to do what you were trying to do. It took me awhile because I got stuck on this but finally got it figured out! I've linked a video above on how to do it with the instructions provided below :)
Sorry if I gave bad instructions 
Notes
This only works for published games.
THE API KEY IS REQUIRED OR THIS WON'T WORK.
Yes, you can use HttpService for this, Roblox allows it for this instance.
Steps
- First you want to go the https://create.roblox.com. Then, select 'All Tools' and then select 'API Keys'. LINK: https://create.roblox.com/dashboard/credentials
- You want to create an API Key called 'Groups_API'.
- For 'Access Permissions' you want to set the API System to 'Groups', NOT 'Legacy Groups' or 'Group Forums'. After that, for the permissions, make sure you have read selected. You can also add write if you want, but it isn't needed in this situation.
- Then, press 'Save & Generate Key'. Once you created the API Key, a long line of text should appear with a button next to the right called 'Copy Key to Clipboard'. Press it.
- Now, on the creator dashboard page, find the game that you're trying to get the users roles in. Once your on the games dashboard page, under configure, select 'Secrets'.
- Create a secret, I'd recommend setting the name to 'Groups_API'. In the secret field, paste your API Key there, then click 'Create'.
- Open your game in studio. In the top left, navigate to File then press Experience Settings. Go to the security tab and make sure 'Allow HTTP Requests' is enabled as this is required to use
HttpService.
- Under that settings, you should see something that says 'Local Secrets', this is required if you wanna test this in studio.
- Click Create and a new line under 'Local Secrets' should appear. It should say something like '(new secret 1)'. Click the 3 dots on the far right of it and do the same steps you did for steps 6 and 7.
- Lastly, create a script somewhere in your game where it can run at and paste the reference code below. (This code was rushed and only prints the role names so feel free to modify the code below.)
local HttpService = game:GetService("HttpService")
local GroupId = 14654842
local URL = "https://apis.roblox.com/cloud/v2/groups/"..GroupId.."/"
local API_Key = HttpService:GetSecret("Groups_API")
function GetRoleName(RoleId)
assert(typeof(RoleId) == "number", "RoleId must be a number.")
local Response = HttpService:RequestAsync({
Url = URL.."roles/"..RoleId,
Method = "GET",
Headers = {
['x-api-key'] = API_Key
}
})
if not Response.Success then return end
local Data = HttpService:JSONDecode(Response.Body)
return Data.displayName
end
function GetUsersRoles(UserId)
assert(typeof(UserId) == "number", "UserId must be a number.")
local GrabbedRoles = {}
local Response = HttpService:RequestAsync({
Url = URL.."memberships?maxPageSize=100&filter=user == 'users/"..UserId.."'",
Method = "GET",
Headers = {
['x-api-key'] = API_Key
}
})
if not Response.Success then return end
local Data = HttpService:JSONDecode(Response.Body)
local Info = Data.groupMemberships[1]
for _, role in pairs(Info.roles) do
local RoleId = tonumber(string.match(role, "roles/(%d+)"))
local RoleName = GetRoleName(RoleId)
table.insert(GrabbedRoles, RoleName)
end
return GrabbedRoles
end
local AllRoles = GetUsersRoles(274200990)
print(AllRoles)
Change the GroupId variable to your Groups ID and then change the UserId on the line with local AllRoles = GetUsersRoles(274200990) to the players id that you're trying to get the roles from.