# BadgeService

Roblox Engine API class from Roblox Studio 0.744.0.7441077 (version-7aaa6838d36c4448).

- Inherits from, nearest first: [Instance](https://rapi.sleaze.dev/classes/Instance.md), [Object](https://rapi.sleaze.dev/classes/Object.md)
- Tags: Not creatable, Service
- Memory category: Instances
- HTML page: https://rapi.sleaze.dev/classes/BadgeService/
- Roblox documentation: https://create.roblox.com/docs/reference/engine/classes/BadgeService

Provides information on badges and awards them.

## Methods

### AwardBadgeAsync

```luau
BadgeService:AwardBadgeAsync(userId: User, badgeId: number): boolean
```

- Tags: Yields, Capabilities: AssetManagement

Award a badge to a player given the ID of each.

Parameters:

- `userId`: The [`Player.UserId`](https://rapi.sleaze.dev/classes/Player.md) of the user the badge is to be awarded to.
- `badgeId`: The ID of the badge to be awarded.

Returns: Boolean of `true` if the badge was awarded successfully.

### CheckUserBadgesAsync

```luau
BadgeService:CheckUserBadgesAsync(userId: User, badgeIds: { any }): { any }
```

- Tags: Yields, Capabilities: AssetManagement

Checks a list of badge IDs against a `UserId` and returns a list of badge IDs that the player owns.

Parameters:

- `userId`: The `UserId` of the player to check for ownership of the specified badges.
- `badgeIds`: The list of IDs of the badges to check ownership of. Maximum length of 10.

Returns: The list of badge IDs the given user owns out of the provided badge IDs. Empty if none of the provided badges are owned by the given user. Not guaranteed to be in the same order as the input list. Some badge IDs may be omitted if the user with the target `userId` has not recently been in the server and the badge IDs are not associated with the requesting experience.

### GetBadgeInfoAsync

```luau
BadgeService:GetBadgeInfoAsync(badgeId: number): { [string]: any }
```

- Tags: Yields, Capabilities: AssetManagement

Fetch information about a badge given its ID.

Parameters:

- `badgeId`: The badge ID of the badge whose information should be fetched.

Returns: A dictionary of information about the specified badge.

### GetUserBadgesAsync

```luau
BadgeService:GetUserBadgesAsync(userId: User, badgeIds: { any }): { any }
```

- Tags: Yields, Capabilities: AssetManagement

Checks a list of badge IDs against a [`User`](https://rapi.sleaze.dev/index/types/User.md) and returns, for each badge the player owns, its ID and the date it was awarded.

Parameters:

- `userId`: The [`User`](https://rapi.sleaze.dev/index/types/User.md) of the player to check for ownership of the specified badges.
- `badgeIds`: The list of IDs of the badges to check ownership of. Maximum length of 100.

Returns: A list of dictionaries, one for each badge the given user owns out of the provided badge IDs. Each dictionary contains a `BadgeId` and an `AwardedDate`. Empty if none of the provided badges are owned by the given user. Not guaranteed to be in the same order as the input list. Some badge IDs may be omitted if the user with the target [`User`](https://rapi.sleaze.dev/index/types/User.md) has not recently been in the server and the badge IDs are not associated with the requesting experience.

### UserHasBadgeAsync

```luau
BadgeService:UserHasBadgeAsync(userId: User, badgeId: number): boolean
```

- Tags: Yields, Capabilities: AssetManagement

Checks whether a player has the badge given the [`Player.UserId`](https://rapi.sleaze.dev/classes/Player.md) and the badge ID.

Parameters:

- `userId`: The [`Player.UserId`](https://rapi.sleaze.dev/classes/Player.md) of the player to check for ownership of the specified badge.
- `badgeId`: The badge ID of the badge whose ownership will be checked.

Returns: Indicates if the specified user has the specified badge.

### AwardBadge

```luau
BadgeService:AwardBadge(userId: User, badgeId: number): boolean
```

- Tags: Deprecated, Yields, Capabilities: AssetManagement
- Use instead: [`BadgeService.AwardBadgeAsync`](https://rapi.sleaze.dev/classes/BadgeService.md)

**Deprecated:** Use [`AwardBadgeAsync()`](https://rapi.sleaze.dev/classes/BadgeService.md) instead.

Award a badge to a player given the ID of each.

Parameters:

- `userId`: The [`Player.UserId`](https://rapi.sleaze.dev/classes/Player.md) of the user the badge is to be awarded to.
- `badgeId`: The ID of the badge to be awarded.

Returns: Boolean of `true` if the badge was awarded successfully.

### IsDisabled

```luau
BadgeService:IsDisabled(badgeId: number): boolean
```

- Tags: Deprecated, Yields, Capabilities: AssetManagement

**Deprecated:** This function is deprecated. Do not use it for new work. Instead, it can be checked by calling BadgeService:GetBadgeInfoAsync() and checking the IsEnabled field.

Returns whether a given badge is disabled.

Parameters:

- `badgeId`: The ID of the badge.

Returns: True if the specified badge is not available to be awarded.

### IsLegal

```luau
BadgeService:IsLegal(badgeId: number): boolean
```

- Tags: Deprecated, Yields, Capabilities: AssetManagement

**Deprecated:** This function is deprecated and will always return true. Do not use it for new work.

Determines if a given badge is associated with the current game.

Parameters:

- `badgeId`: The badge ID of the badge.

Returns: True if the badge is associated with the current game.

### UserHasBadge

```luau
BadgeService:UserHasBadge(userId: User, badgeId: number): boolean
```

- Tags: Deprecated, Yields, Capabilities: AssetManagement

**Deprecated:** This method has been superseded by [`BadgeService:UserHasBadgeAsync()`](https://rapi.sleaze.dev/classes/BadgeService.md) which should be used for new work instead.

Checks whether a user has the badge given the [`Player.UserId`](https://rapi.sleaze.dev/classes/Player.md) and the badge ID.

Parameters:

- `userId`: The user ID of the user.
- `badgeId`: The badge ID of the badge.

Returns: True if the user has the badge.

## Events

### BadgeAwarded

```luau
BadgeService.BadgeAwarded: RBXScriptSignal<(message: string, userId: number, badgeId: number)>
```

- Tags: Roblox script security, Capabilities: AssetManagement

### OnBadgeAwarded

```luau
BadgeService.OnBadgeAwarded: RBXScriptSignal<(userId: number, creatorId: number, badgeId: number)>
```

- Tags: Roblox script security, Capabilities: AssetManagement

## Inherited members

- From [Instance](https://rapi.sleaze.dev/classes/Instance.md): `Archivable`, `archivable`, `Attributes`, `AttributesReplicate`, `AttributesSerialize`, `HistoryId`, `Name`, `Parent`, `PredictionMode`, `PropertyStatusStudio`, `RobloxLocked`, `SerializedOverrides`, `SourceAssetId`, `Tags`, `UniqueId`, `numExpectedDirectChildren`, `DataCost`, `Capabilities`, `DefinesCapabilities`, `IsInSandbox`, `Sandboxed`, `AddTag`, `ClearAllChildren`, `Clone`, `Destroy`, `FindFirstAncestor`, `FindFirstAncestorOfClass`, `FindFirstAncestorWhichIsA`, `FindFirstChild`, `FindFirstChildOfClass`, `FindFirstChildWhichIsA`, `FindFirstDescendant`, `GetActor`, `GetAttribute`, `GetAttributeChangedSignal`, `GetAttributes`, `GetChildren`, `GetDebugId`, `GetDescendants`, `GetFullName`, `GetStyled`, `GetStyledPropertyChangedSignal`, `GetTags`, `HasTag`, `IsAncestorOf`, `IsDescendantOf`, `IsPropertyModified`, `QueryDescendants`, `RemoveTag`, `ResetPropertyToDefault`, `SetAttribute`, `WaitForChild`, `Remove`, `children`, `clone`, `destroy`, `findFirstChild`, `getChildren`, `isDescendantOf`, `remove`, `AncestryChanged`, `AttributeChanged`, `ChildAdded`, `ChildRemoved`, `DescendantAdded`, `DescendantRemoving`, `Destroying`, `StyledPropertiesChanged`, `childAdded`
- From [Object](https://rapi.sleaze.dev/classes/Object.md): `ClassName`, `className`, `GetPropertyChangedSignal`, `IsA`, `isA`, `Changed`
