SafeBadges
Introduction
SafeBadges is an open-source Roblox module designed to simplify and enhance the process of awarding badges within your game (… or experience). With SafeBadges, you can award badges to players with reliability, safety, and precision.
Key Features
“Well, what do you mean by reliable, safe and precise?”
- Reliable: SafeBadges handles the process of awarding badges efficiently and retries automatically if something goes wrong, so you don’t have to worry about any potential failed results.
- Safe: It includes checks to prevent issues like awarding the same badge multiple times unnecessarily and manages retries to avoid infinite loops.
- Precise: With clear error handling and retry logic, SafeBadges ensures that badges are awarded correctly and provides useful logs to help with troubleshooting.
Why use SafeBadges?
SafeBadges is perfect for developers who want an easy way to manage badges. It offers:
- Automatic Retries: If awarding a badge fails, SafeBadges will retry automatically, using a backoff strategy to handle temporary problems smoothly.
- Detailed Errors: When something goes wrong, SafeBadges gives detailed error logs, so you can quickly figure out what happened and fix it.
- Easy Integration: Adding SafeBadges to your game is straightforward, letting you focus on creating other features instead of having to worry about badges.
Whether you’re rewarding players for achievements, in-game events, or any other reason—which I can’t possibly list here, as that list would go on forever—SafeBadges ensures they receive their badges reliably and with minimal effort on your end.
Installation
To start using SafeBadges, just add the module to your game, and require it from a server script!
There are 4 settings you can edit in the module to your liking: ATTEMPT_LIMIT: number
, RETRY_DELAY: number
, BACKOFF_FACTOR: number
, and DEBUG_PRINTS: boolean
.
Get the module here 👇
Example Usage 👇
-- Variables
local Players = game:GetService("Players")
local ServerScriptService = game:GetService("ServerScriptService")
local ServerModules: Folder = ServerScriptService.ServerModules
-- Require the module
local SafeBadges: ModuleScript = require(ServerModules.SafeBadges)
-- A little list of badge IDs so we have a variety
local badgeIds = {1234567890, 0987654321, 1048249946058447} :: {number}
-- Welcome badge:
Players.PlayerAdded:Connect(function(player: Player)
SafeBadges.AwardBadges(player, badgeIds)
end)
-- Check badge ownership:
Players.PlayerAdded:Connect(function(player: Player)
local OwnedBadges = SafeBadges.HasBadges(player, badgeIds)
return print(OwnedBadges)
-- returns (and prints) an array of owned badges
end)
-- Change a fast flag:
SafeBadges.SetFastFlag("DEBUG_PRINTS", false)
Have any suggestions/bugs/issues?
You can reach out to me via the DevForum, and I’ll try my best to respond as fast as I can!