PcoWSkbVqDnWTu_dm2ix
Collapse Sidebar

UserHasBadgeAsync

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 a ModuleScript eventually required by a Script, not from a LocalScript.
  • 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 Player/UserId of the player to check for ownership of the specified badge.

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.