Can you use :GetRoleInGroup() for player names?

Hello everyone!

I’m wondering if I can use :GetRoleInGroup() for a player name. I’ve checked and it’s said that you need to use it for the player but as an example;

game.Players.PlayerAdded:Connect(function(player)
	print(player:GetRoleInGroup(groupid)
end

But instead is there a way to do it just for the player name or userid? For example like mrflimflam:GetRoleInGroup(groupid)

I’m trying to get their name from an api but I want their rank too.

Thanks in advance!

This is the bit of my script but it doesn’t work:

Frame.Card2.User.Text = Data["data"][2]["poster"]["displayName"].." | "..Data["data"][2]["poster"]:GetRoleInGroup(groupId)

Well get role in group can work for any player in the actual game, and won’t work for any random username.

How would I go about getting a players role if they aren’t in the game?

This might not be the best solution, but you could possibly use GroupService:GetGroupsAsync() for this. It uses a userID.

You’d have to loop through every group, check the group id to see if it’s the right group, and then check the role. It’s pretty scuffed, but I don’t know of any other method.

You can only perform the “GetRoleInGroup()” function through a player instance (as such that player must currently be a valid player object in the game when the function is called, to do what you’re describing you will need to make use of one of the group API endpoints, in specific this one.

https://groups.roblox.com/docs#!/Membership/get_v1_users_userId_groups_roles

It takes a user ID and provides a list of groups the user matching the specified user ID is in with their roles in those groups (this includes the name of the role and the rank).

Here’s a sample request for example.

https://groups.roblox.com/v1/users/261/groups/roles

Cant you use:

game.Players.PlayerAdded:Connect(function(Player)
    Frame.Card2.User.Text = Player.DisplayName.." | "..Player:GetRankInGroup(groupId)
end)

Hes talking about players not in game. So using a username

1 Like

Then that’s quite impossible. It would require using Https service, which is disabled for Roblox to prevent them from getting DDosed.

1 Like

I have a proxy which I can use so that’s not an issue.

Wouldn’t this work? :grinning_face_with_smiling_eyes:

No because the player that I want the rank from isn’t in the game.

then use the roblox web api to get their rank*

What are you making? I could help you further from there.

Then use GroupService.

No, GroupService works just fine.