You can write your topic however you want, but you need to answer these questions:
-
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.
-
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.
-
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!