How to use badge service to create a welcome badge

Ahoy Everyone, and I am going to show you how to reward a welcome badge when the player joins the game.

Once your on studio and in the game you want to add a badge so click “game settings”
image

Once in the game settings page click on “Monetization”
image

Click the “Create” button on the top right here
image

Now it shows you all of your creations hover over the creation you want your badge to be in and click the three dots

Then click the “Create badge” button, So name the badge whatever you like. Then upload the image you want for your badge also add a description. and check if the badge is enabled is toggled on. If it is then hit the “Create Badge” button at the bottom of the page

once your in the badge page hover over your badge and click the 3 dots click “copy asset ID”
now that your badge is created lets go back in studio.

add a script in Server Script Service and write

local badgeService = game:GetService("BadgeService") --calls badge service

local badgeID = 0 --badge id here

game.Players.PlayerAdded:Connect(function(player)
	task.wait(.5) --waits to give badge
	badgeService:AwardBadge(player.UserId, badgeID) --awards badge
end)

—now test it out and there you go you now have a working welcome badge for your roblox game :smiley:

some edits done by @Average_FreeTooPlay

15 Likes

Good tutorial, definitely beginner friendly.

You might want to add a check to see if the player already has the badge so it doesn’t throw a warning in the output.

local badgeService = game:GetService("BadgeService") --calls upon badge service
local badgeID = 0 --your badge id here

game.Players.PlayerAdded:Connect(function(player)
	task.wait(.5) --waits a little to give the badge (don't use wait() it's equally inefficient and memory consuming)
    if badgeService:UserHasBadgeAsync(player.UserId,badgeID) then
	   badgeService:AwardBadge(player.UserId,badgeID) --awards the badge
    end
end)
6 Likes

I was gonna do a task.wait but I thought “wait()” was more simple and I edited the post to match your script but thanks for the feedback :smiley: (also I dont thing the if statement works I tried it)

2 Likes

shouldn’t it be

game.Players.PlayerAdded:Connect(function(player)
	task.wait(.5) --waits a little to give the badge (don't use wait() it's equally inefficient and memory consuming)
    if not badgeService:UserHasBadgeAsync(player.UserId,badgeID) then
	   badgeService:AwardBadge(player.UserId,badgeID) --awards the badge
    end
end)

since you should be checking if the player doesn’t have the badge

6 Likes

To be honest, I don’t even know what i was thinking when i made that post. Thanks for commenting about that!

(seriously tho, what is wrong with me recently? don’t know if its the mental issues affecting my health.)

1 Like

hey all of us do mistakes
even the best of us
don’t worry

5 Likes