PcoWSkbVqDnWTu_dm2ix
Collapse Sidebar

AwardBadge

AwardBadge grants a Player a articles/Badges Special Game Awards|badge given the player’s Player/UserId|UserId and the badge ID. In order to successfully award a badge, the following criteria must be met:

  • The player must be presently connected to the game.
  • 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-side Script or a ModuleScript eventually required by a Script, not from a LocalScript.
  • The badge must be awarded in a place that is part of the game associated with the badge.
  • The owner of the place must also own the badge (for example, the owner must not have deleted the badge).
  • The badge must be enabled; check this using the IsEnabled property of the badge fetched via BadgeService/GetBadgeInfoAsync|BadgeService:GetBadgeInfoAsync().

See also

  • BadgeService/GetBadgeInfoAsync|BadgeService:GetBadgeInfoAsync()
  • BadgeService/UserHasBadgeAsync|BadgeService:UserHasBadgeAsync()

Parameters

Name Type Default Description

The Player/UserId of the user the badge is to be awarded to.

The ID of the badge to be awarded.

Returns

Return Type Summary

Boolean of true if the badge was awarded successfully.


Code Samples


Awarding a Badge

Using the following example, the awardBadge() function can be called whenever it fits your game design. Using properties of the badge fetched via BadgeService/GetBadgeInfoAsync|BadgeService:GetBadgeInfoAsync(), it confirms that the badge can be awarded and does so using BadgeService/AwardBadge|BadgeService:AwardBadge().