UserHasBadgeAsync
This is a yielding function. When called, it will pause the Lua thread that called the function until a result is ready to be returned, without interrupting other scripts.
Checks whether a Player
owns a articles/Badges Special Game Awards|badge
given their Player/UserId|UserId
and the badge ID. This query can only be made under the following conditions:
- This function must be called from a server-side
Script
or aModuleScript
eventually required by aScript
, not from aLocalScript
. - The player in question must be present in the server.
Any badge for any game can be queried, no matter who created the badge or which game it is used for.
See also
BadgeService/GetBadgeInfoAsync|BadgeService:GetBadgeInfoAsync()
BadgeService/AwardBadge|BadgeService:AwardBadge()
Parameters
Name | Type | Default | Description |
---|---|---|---|
|
The |
||
|
The badge ID of the badge whose ownership will be checked. |
Returns
Return Type | Summary |
---|---|
A boolean indicating if the specified user has the specified badge. |
Code Samples
Checking Earned Badges
The following script waits for any player to enter the game and checks if they own a specific badge. This is useful for creating a articles/Collision Filtering Team Doors|restricted area
or articles/Teleporting Between Places|teleporter
that only works if a player owns a special badge.