Badges/Achievement Inventory

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? I want to know if it is possible to display the badges in my game in the shop section so people can see which badges they have received and which badges they have yet to get. I want to make it so in the script it calls forth the name of the badge, the thumbnail image and even the description if possible.

  2. What is the issue? I have no idea how I would go about doing that. I have a script function already in accordance with getting badges in my game. It is pretty simple script where you touch a part to get the badge. But that function is to award the badge and not getting the badge information.

  3. What solutions have you tried so far? I did try looking for solutions on the developer forum and on YT but, for the most part, a majority of the tutorials only aimed at showing how to award badges in game which I already know how to do. I also looked up
    BadgeService:GetBadgeInfoAsync
    to get more information on how to script it but honestly the script it shows confuses me.

Heres the script I use to award the badge:

local badgeservice = game:GetService("BadgeService")
local id = 2125712920

script.Parent.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
		badgeservice:AwardBadge(plr.UserId,id)
	end
end)

Now would it be possible to have a badge inventory system at the shop so people can scan over badges they have and badges they have yet to get? If it is possible, would the script look similar to the one I provided up above?

This script down below is the script provided in the dev forum for the GetBadgeInfoASync which I tried to use in my game but it didn’t work the way I wanted it to.

local BadgeService = game:GetService("BadgeService")

-- Fetch badge information
local success, result = pcall(function()
	return BadgeService:GetBadgeInfoAsync(2125585473)  -- Change this to desired badge ID
end)

-- Output the information
if success then
	print("Badge:", result.Name)
	print("Enabled:", result.IsEnabled)
	print("Description:", result.Description)
	print("Icon:", "rbxassetid://" .. result.IconImageId)	
else
	warn("Error while fetching badge info:", result)
end

Any help would be greatly appreciated. I am very new with scripting so I am learning as I move along in this process so anything would be helpful. I can also provide any sort of screenshots if needed. Thank you!

Won’t go into serious details to explain it and all, but you can achieve this quite simply.
You can input the badge IDs in a table, loop through it and if the player has it, show however you like that its unlocked and vice versa for locked badges.

Not really that complicated, you can find a lot of tutorials which you can scrap up for this.

Thanks for the direction! I’ve never heard of tables when it comes to scripting because I’m still new at it and learning as I go by. Is there anything in particular I need to look up when it comes to tables or just by searching “tables” I’ll get the answer I need? And for the tables, is it possible to have it display the image thumbnail and name? Thanks again for the help!

You make a table like

local IDs = {}

In which you can store the badge IDs, then do a for i loop which lets you go through each value in it and use the ID with the badge service like you fetched the badge info. You should be able to figure it out from there. I suggest looking up some code examples and tutorials if you’re still confused.

1 Like

Thanks! This well definitely push me in the right direction. Appreciate the help!

1 Like