PcoWSkbVqDnWTu_dm2ix
We use cookies on this site to enhance your user experience
Collapse Sidebar

IsLegal

This function determines if a given badge is associated with the current game. It returns true if the badge is associated with the current game.

Badges can only be awarded from a place that is part of the game associated with the badge. This means, for example, a developer cannot award a badge associated with another developer’s game.

Even if this returns true, a badge may still not be award-able. For example, it may be disabled. For more information on the criteria for awarding badges see BadgeService/AwardBadge|AwardBadge.

Parameters

Name Type Default Description

The badge ID of the badge.

Returns

Return Type Summary

True if the badge is associated with the current game.


Code Samples


Awarding a Badge

This code sample includes a simple function for awarding a badge.

    local BadgeService = game:GetService("BadgeService")
    
    local function awardBadge(player, badgeId)
    	-- check badge can be awarded
    	if BadgeService:IsLegal(badgeId) and not BadgeService:IsDisabled(badgeId) then
    		-- award badge
    		BadgeService:AwardBadge(player.UserId, badgeId)
    	end
    end