Service · inherits Instance
BadgeService
Provides information on badges and awards them.
About BadgeService
BadgeService provides information and functionality related to
badges. Badges are used across the
platform to recognize a player's achievements and activity. Upon awarding a
badge to a player, it is added to their inventory and displayed on their
profile page.
Methods 5
AwardBadgeAsync
(userId: User, badgeId: int64) → booleanYieldsAward a badge to a player given the ID of each.Grants a
Playera badge with theUserIdand the badge ID.In order to successfully award a badge:
- The player must be presently connected to the experience.
- The player must not already have the badge (note that a player may delete an awarded badge from their profile and be awarded the badge again).
- The badge must be awarded from a server script (a
ScriptwithRunContextofRunContext.ServerorRunContext.Legacy) or aModuleScripteventually required by one, not from a client script. - The badge must be awarded in a place that is part of the experience associated with the badge.
- The badge must be enabled; check this using the
IsEnabledproperty of the badge fetched throughBadgeService.GetBadgeInfoAsync.
Rate limit is
50 + 35 * [number of users]per minute.CheckUserBadgesAsync
(userId: User, badgeIds: Array) → ArrayYieldsChecks a list of badge IDs against aUserIdand returns a list of badge IDs that the player owns.Checks a list of badge IDs against a
UserIdand returns a list of badge IDs that the player owns. This method supports batches of up to 10 badges; useBadgeService.UserHasBadgeAsyncfor single badge lookups.When called from a server script, any
UserIdcan be used. If the user with the target user ID has not recently been in the server, only badge IDs that are associated with the requesting experience will be checked, and any badge IDs that are not associated with the requesting experience will not be included in the response (as if they were not owned).For users that have recently been in the server, any badges for any experiences can be queried, no matter who created the badge or which experience it is used for.
In a client script (a
LocalScriptor aScriptwithRunContextofRunContext.Client), only theUserIdof the local user whose client is running the script can be used.Rate limit is
10 + 5 * [number of players]per minute in each server.GetBadgeInfoAsync
(badgeId: int64) → DictionaryYieldsFetch information about a badge given its ID.This method fetches information about a badge given its ID and returns a dictionary with the following fields:
This method takes a brief moment to load the information from Roblox; repeated calls will cache for a short duration.
GetUserBadgesAsync
(userId: User, badgeIds: Array) → ArrayYieldsChecks a list of badge IDs against aUserand returns, for each badge the player owns, its ID and the date it was awarded.Checks a list of badge IDs against a
Userand returns, for each badge the player owns, a dictionary containing the badge's ID and the date it was awarded. This method supports batches of up to 100 badges; useBadgeService.UserHasBadgeAsyncfor single badge lookups.Each entry in the returned list is a dictionary with the following fields:
When called from a server script, any
Usercan be used. If the user with the targetUserhas not recently been in the server, only badge IDs that are associated with the requesting experience will be checked, and any badge IDs that are not associated with the requesting experience will not be included in the response (as if they were not owned).For users that have recently been in the server, any badges for any experiences can be queried, no matter who created the badge or which experience it is used for.
In a client script (a
LocalScriptor aScriptwithRunContextofRunContext.Client), only theUserof the local user whose client is running the script can be used.Rate limit is
10 + 5 * [number of players]per minute in each server.UserHasBadgeAsync
(userId: User, badgeId: int64) → booleanYieldsChecks whether a player has the badge given thePlayer.UserIdand the badge ID.Checks and returns whether a
Playerowns a badge given theirUserIdand the badge ID. You can call this method from a server script or aModuleScripteventually required by one. When calling this method from a client script (aLocalScriptor aScriptwithRunContextofRunContext.Client), it only works for the local user whose client is running the script.When called from a server script, any
UserIdcan be used. If the user with the target user ID has not recently been in the server, only badge IDs that are associated with the requesting experience will be checked. If the requested badge ID is not associated with the requesting experience and the target user has not recently been in the server, the method behaves as if the badge is not owned.For users that have recently been in the server, any badge for any experience can be queried, no matter who created the badge or which experience it is used for.
Rate limit is
50 + 35 * [number of players]per minute.
BadgeService also has every member of Instance. Deprecated and Roblox-only members are hidden.
Reference text from the Roblox Creator Documentation, licensed CC BY 4.0, reorganized by rbxtoolshub.com · Studio 0.743.0.7431133.