Class
GroupService
NotCreatableServiceNotReplicated
GroupService is a service that allows developers to fetch information about a Roblox group from within a game.
GroupService is a service that allows developers to fetch information about
a Roblox group from within a game.
Basic information on the group, including its name, description, owner, roles
and emblem can be fetched using GroupService:GetGroupInfoAsync().
Lists of a group's allies and enemies can be fetched using
GroupService:GetAlliesAsync() and
GroupService:GetEnemiesAsync().
GroupService can also be used to fetch a list of groups a player is a member
of, using GroupService:GetGroupsAsync(). If you wish to verify if a
player is in a group, use the Player:IsInGroupAsync() method rather
than GroupService:GetGroupsAsync().
The service has a number of useful applications, such as detecting if a player
is an ally or enemy upon joining the game, or prompting a player to join a
group using the GroupService:PromptJoinAsync() method.
Methods 6#
| GetAlliesAsync | Returns a StandardPages object including information on all of the
specified group's allies.Yields |
| GetEnemiesAsync | Returns a StandardPages object including information on all of the
specified group's enemies.Yields |
| GetGroupInfoAsync | Returns a table containing information about the given group.Yields |
| GetGroupsAsync | Returns a list of tables containing information on all of the groups a given player is a member of.Yields |
| GetRolesInGroupAsync | Returns all roles held by the specified user in the specified group, supporting multi-role group membership.Yields |
| PromptJoinAsync | Prompts the local Player to join a specified Roblox group via a
native modal.Yields |
GetAlliesAsync(groupId: int64): StandardPages#
Yields
Returns a StandardPages object including information on all of the
specified group's allies.
This pages does not include a list of group IDs but instead a list of
group information tables, mirroring the format of those returned by
GroupService:GetGroupInfoAsync(). See below for the structure of
these tables.
group = {
Name = "Knights of the Seventh Sanctum",
Id = 377251,
Owner = {
Name = "Vilicus",
Id = 23415609
},
EmblemUrl = "http://www.roblox.com/asset/?id=60428602",
Description = "We fight alongside the balance to make sure no one becomes too powerful",
Roles = {
[1] = {
Name = "Apprentice",
Rank = 1
},
[2] = {
Name = "Warrior",
Rank = 2
},
[3] = {
Name = "Earth Walker",
Rank = 255
}
}
}Note, as this function returns a StandardPages object rather than
an array, developers may wish to convert it to an array for ease of use
(see examples).
This function has a number of useful applications, including detecting if a player is a member of an allied group.
For enemies, use GroupService:GetEnemiesAsync().
| Name | Type | Default | Description |
|---|---|---|---|
groupId | int64 | The group's ID. |
Returns
StandardPages— AStandardPagesobject containing group information tables for each of the specified group's allies.
GetEnemiesAsync(groupId: int64): StandardPages#
Yields
Returns a StandardPages object including information on all of the
specified group's enemies.
This pages does not include a list of group IDs but instead a list of
group information tables, mirroring the format of those returned by
GroupService:GetGroupInfoAsync(). See below for the structure of
these tables.
group = {
Name = "Knights of the Seventh Sanctum",
Id = 377251,
Owner = {
Name = "Vilicus",
Id = 23415609
},
EmblemUrl = "http://www.roblox.com/asset/?id=60428602",
Description = "We fight alongside the balance to make sure no one becomes too powerful",
Roles = {
[1] = {
Name = "Apprentice",
Rank = 1
},
[2] = {
Name = "Warrior",
Rank = 2
},
[3] = {
Name = "Earth Walker",
Rank = 255
}
}
}Note, as this function returns a StandardPages object rather than
an array, developers may wish to convert it to an array for ease of use
(see examples).
This function has a number of useful applications, including detecting if a player is a member of an enemy group.
For allies, use GroupService:GetAlliesAsync().
| Name | Type | Default | Description |
|---|---|---|---|
groupId | int64 | The group's ID. |
Returns
StandardPages— AStandardPagesobject containing group information tables for each of the specified group's enemies.
GetGroupInfoAsync(groupId: int64): Variant#
Yields
Returns a table containing information about the given group.
The table returned is the same format as that returned in
GroupService:GetAlliesAsync() and
GroupService:GetEnemiesAsync(). This format can be seen below.
group = {
Name = "Knights of the Seventh Sanctum",
Id = 377251,
Owner = {
Name = "Vilicus",
Id = 23415609
},
EmblemUrl = "http://www.roblox.com/asset/?id=60428602",
Description = "We fight alongside the balance to make sure no one becomes too powerful",
Roles = {
[1] = {
Name = "Apprentice",
Rank = 1
},
[2] = {
Name = "Warrior",
Rank = 2
},
[3] = {
Name = "Earth Walker",
Rank = 255
}
}
}Note, if a group has no owner the Owner field will be set to nil.
This function has a number of useful applications, including loading the latest description and logo of a group for display in a group base.
| Name | Type | Default | Description |
|---|---|---|---|
groupId | int64 | The group ID of the group. |
Returns
Variant— A dictionary of information about the group.
GetGroupsAsync(userId: User): Array#
Yields
This function returns a list of tables containing information on all of
the groups a given Player is a member of.
The list returned will include an entry for every group the player is a member of. These entries are tables with the following fields.
| Name | Description |
|---|---|
| Name | The group's name |
| Id | The group ID |
| EmblemUrl | An asset url linking to the group's thumbnail (for example: http://www.roblox.com/asset/?id=276165514) |
| EmblemId | The assetId of the emblem, the same which is used in the EmblemUrl |
| Rank (deprecated) | The rankId the player has. Deprecated: players may now hold more than one role in a group. Use Class.GroupService:GetRolesInGroupAsync() instead. |
| Role (deprecated) | The name of the player's group rank. Deprecated: players may now hold more than one role in a group. Use Class.GroupService:GetRolesInGroupAsync() instead. |
| IsPrimary | A boolean indicating if this is the player's primary group |
| IsInClan (deprecated) | Always false. Deprecated: the Clans feature has been sunset. |
Note unlike GroupService:GetAlliesAsync() and
GroupService:GetEnemiesAsync(), GetGroupsAsync returns a table
rather than a StandardPages object.
| Name | Type | Default | Description |
|---|---|---|---|
userId | User | The Player.UserId of the user. |
Returns
Array— An array of dictionaries containing information on the group's thePlayeris a member of.
GetRolesInGroupAsync(userId: User, groupId: int64): Variant#
Yields
Returns a table describing all roles the specified user holds in the specified group. In a multi-role world, a user may belong to more than one role simultaneously.
The returned table has the following structure:
| Key | Type | Description |
|---|---|---|
| IsMember | boolean | true if the user is a member of the group |
| Roles | array | Array of role tables (empty if not a member or no non-base roles) |
Each entry in the Roles array has the following structure:
| Key | Type | Description |
|---|---|---|
| Id | integer | Unique role ID |
| Name | string | Display name of the role |
| Rank | integer | Rank value (0–255) |
The Roles array is ordered from the highest role to the lowest role.
Only public roles are included. A role's Rank value is retained for
backwards compatibility, but does not determine its position in the role
hierarchy. Use the stable Id to identify a role.
This method supersedes Player:GetRankInGroupAsync() and
Player:GetRoleInGroupAsync(), which return only the member's
highest public role.
This call may not yield the most up-to-date information. Results are
cached per user and group, so multiple calls with the same userId and
groupId may yield the same result until the cache expires. The caching
behavior is on a per-peer basis: a server does not share the same cache as
a client.
When a player joins a group in-experience due to a call to
GroupService:PromptJoinAsync(), any cached result for that player
and group will be cleared on the client where the prompt was shown.
| Name | Type | Default | Description |
|---|---|---|---|
userId | User | The user's ID. | |
groupId | int64 | The group's ID. |
Returns
Variant— A table with two fields:IsMember(boolean) andRoles(array of public role tables). Each role table containsId(integer),Name(string), andRank(integer). The array is ordered from highest to lowest role.
PromptJoinAsync(groupId: int64): GroupMembershipStatus#
Yields
PromptJoinAsync() displays a prompt to the local player through which
they may join the specified Roblox group. The group must exist and the
player must meet the eligibility criteria to join. If the player is
ineligible, this method will return GroupMembershipStatus.None.
Note that you can use Player:IsInGroupAsync() to check the
player's current membership status before calling this method.
If the player successfully joins, any cached results from
GroupService:GetRolesInGroupAsync(),
Player:GetRankInGroupAsync(), and
Player:GetRoleInGroupAsync() for that player and group will be
cleared on the client where the prompt was shown.
| Name | Type | Default | Description |
|---|---|---|---|
groupId | int64 | ID of the group to prompt the player to join. This must be a valid group ID. |
Returns
GroupMembershipStatus—GroupMembershipStatusindicating the player's group membership status after the prompt is closed. If the player closes the prompt without joining, this will returnGroupMembershipStatus.Noneor their previous status if they were already a member.
Inherited members#
Inherited from Instance 58
Properties (10)
Archivable, archivable, Capabilities, IsInSandbox, Name, Parent, PredictionMode, RobloxLocked, Sandboxed, UniqueId
Methods (39)
AddTag, children, ClearAllChildren, Clone, clone, Destroy, destroy, FindFirstAncestor, FindFirstAncestorOfClass, FindFirstAncestorWhichIsA, FindFirstChild, findFirstChild, FindFirstChildOfClass, FindFirstChildWhichIsA, FindFirstDescendant, GetActor, GetAttribute, GetAttributeChangedSignal, GetAttributes, GetChildren, getChildren, GetDebugId, GetDescendants, GetFullName, GetStyled, GetStyledPropertyChangedSignal, GetTags, HasTag, IsAncestorOf, IsDescendantOf, isDescendantOf, IsPropertyModified, QueryDescendants, Remove, remove, RemoveTag, ResetPropertyToDefault, SetAttribute, WaitForChild