Badges – Special Game Awards
Badges – Special Game Awards
Badges allow you to create special awards for players who do something exceptional within your game — think of it like when your teacher gives you a gold star on a test for getting a perfect score. Badges are a great way to encourage players in your game, and many players will want to collect them all!
A badge might be awarded when a player:
- Collects 100 gold stars in the game.
- Jumps across a challenging series of platforms over a poison swamp.
- Finds all 7 spirit keys to to unlock the kingdoms of Earth, Air, Lava, Ocean, Light, Shadow, and Dreams.
Creating a Badge
It costs R$ 100 to create a badge. To begin, go to the Create page on the Roblox website. Once there, make sure that the My Creations tab is selected and that Games is selected in the left column.
Now follow these steps to create a badge:
- Determine the game you want to create a badge for.
- In the settings drop-down menu on the right-hand side, select Create Badge.
Create an Icon
Badges require an image of exactly 150×150 pixels. These steps will help you create an icon.
- Save the following template for a circular badge icon to your computer by right-clicking the image and selecting Save Image As….
- In an image editor or drawing application, fill in the blank circular area with some artwork.
- Save the badge image with a new file name (if you plan to create more than one badge for your game, you shouldn’t save over the original template file).
- The black corners will be invisible in the final image, so be careful not to draw over them!
- Do not resize the template — uploaded badge images must be exactly 150×150 pixels to display properly on the Roblox website.
Upload the Badge
The last step in the creation process is uploading the badge.
- Back on the Roblox website, click the small button next to Find your image.
- Find the badge image on your computer and confirm that you’d like to upload it.
- Type in a name and description for the badge. Remember to tell players how to earn the badge so they have a specific goal to reach for!
- When you’re ready, click Preview. On the next screen, review the details for the badge and purchase when you’re ready. Once the purchase is complete, the badge will appear further down on the My Creations → Badges page.
Scripting for Badges
To take full advantage of badges, you’ll need to use scripting. Here are some common examples:
Awarding a Badge
In the following script, the
awardBadge() function can be called whenever it fits your game design, for instance when a player touches the final platform of a challenging jumping sequence. Using
BadgeService functions, it checks if the player already owns the badge and, if not, awards it using
local BadgeService = game:GetService("BadgeService") local Players = game:GetService("Players") local badgeID = 0000000 -- Change this to your badge ID local function awardBadge() local player = Players.LocalPlayer local hasBadge = false -- Check if the player already has the badge local success, message = pcall(function() hasBadge = BadgeService:UserHasBadgeAsync(player.UserId, badgeID) end) -- If there's an error, issue a warning and exit the function if not success then warn("Error while checking if player has badge: " .. tostring(message)) return end if hasBadge == false then BadgeService:AwardBadge(player.UserId, badgeID) end end
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 example, in creating a locked door or teleporter that only works if a player owns a special badge.
local BadgeService = game:GetService("BadgeService") local Players = game:GetService("Players") local badgeID = 0000000 -- Change this to your badge ID local function onPlayerAdded(player) local hasBadge = false -- Check if the player has the badge local success, message = pcall(function() hasBadge = BadgeService:UserHasBadgeAsync(player.UserId, badgeID) end) -- If there's an error, issue a warning and exit the function if not success then warn("Error while checking if player has badge: " .. tostring(message)) return end if hasBadge == true then -- Assign this player a property/indicator that they own the badge -- end end -- Connect 'PlayerAdded' events to the 'onPlayerAdded()' function Players.PlayerAdded:Connect(onPlayerAdded)
Badges are a great way to inspire players to overcome specific challenges and encourage them to spend more time in your game. Hopefully this tutorial inspires you to add a variety of unique badges to your own games!