PcoWSkbVqDnWTu_dm2ix
We use cookies on this site to enhance your user experience
Collapse Sidebar

GetRoleInGroup

The GetRoleInGroup Player function returns the player’s role in the group as a string, or Guest if the player isn’t part of the group.

##Note
Using this in a Script, as opposed to a LocalScript, will not get you the most up-to-date information. If a player leaves a group while they are in the game, GetRoleInGroup will still think they’re in that group until they leave. However, this does not happen when used with a LocalScript.

This is because the method caches results, so multiple calls of GetRoleInGroup on the same player with the same group ID will yield the same result as when the method was first called with the given group ID. The caching behavior is on a per-peer basis: a server does not share the same cache as a client.

Parameters

Name Type Default Description

The groupId of the specified group.

Returns

Return Type Summary

The player’s role in the specified group, or Guest of the player is not a member.


Code Samples


How to Check a Player's Role in a Group

The code below will print the name of the rank that the player is currently a part of, in a specific group. In this instance we’re checking what rank the player is within a group which has a group ID of 2.

game.Players.PlayerAdded:Connect(function(player)
    print("Player is ranked as '" .. player:GetRoleInGroup(2) .. "' in group, 'LOL'!")
end)