Badge
Badge management class for awarding badges to players.
Use the Badge.add
method to add badges to the cache.
Example:
-- Setup
local Badge = require(game.ReplicatedStorage.Packages.Badge)
Badge.add("BadgeName", 999999999)
-- Server
local hasBadge = Badge.has(player, "BadgeName")
print(`Player has badge: {hasBadge}!`)
if not hasBadge then
Badge.award(player, "BadgeName")
end
Install with wally by adding the following to your wally.toml
:
Badge = "dig1t/badge@1.0.5"
Functions
add
Badge.
add
(
name:
string
,
--
The name of the badge.
badgeId:
number
--
The id of the badge.
) →
(
)
Adds a badge to the cache.
Badge.add("BadgeName", 999999999)
has
Badge.
has
(
badgeName:
string
--
The name of the badge.
) →
boolean
--
Whether the player has the badge or not.
Checks if a player has a badge.
local hasBadge = Badge.has(player, "BadgeName")
award
Badge.
award
(
badgeName:
string
--
The name of the badge.
) →
boolean
--
Whether the badge was awarded or not. If the badge was already awarded, this will return true.
Awards a badge to a player.
local awarded: boolean = Badge.award(player, "BadgeName")
if not awarded then
print("Failed to award badge!")
end
print("Badge awarded!")