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

GetRankInGroup

The GetRankInGroup Player function returns the player’s rank in the group as an integer between 0 and 255, where 0 is a non-member and 255 is the group’s owner.

##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, GetRankInGroup 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 GetRankInGroup 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

int

The player’s rank in the group.


Code Samples


How to Check a Player's Rank in a Group

The code below will check if a player that has entered the game has a rank equal to 255, in a group with an ID of 2. If they are, it will print “Player is the owner of the group, ‘LOL’!”, otherwise “Player is NOT the owner of the group, ‘LOL’!” will be printed to the output.

game.Players.PlayerAdded:Connect(function(Player)
    if Player:GetRankInGroup(2) == 255 then
        print("Player is the owner of the group, 'LOL'!")
    else
        print("Player is NOT the owner of the group, 'LOL'!")
    end
end)