Key you are using is invisible. Therefore, keep the TextButton/ImageButton invisible until the player has earned the badge. In both articles you attached the key line of code you’ll require is;
local success, hasBadge = pcall(BadgeService.UserHasBadgeAsync, BadgeService, player.UserId, badgeID)
-- The variable 'hasBadge' will either return true/false
Depending on what the pcall function returns, either true/false you can do a if statement.
if hasBadge then
-- code here
end
Because you are having multiple badges, I’d suggest using a table to contain all of the ids and do something similar below,
local Badges = {
0000000, -- Level 1
0000000 -- Level 2
} -- Place IDs here!
for Index,BadgeID in ipairs(Badges) do
local success, hasBadge = pcall(BadgeService.UserHasBadgeAsync, BadgeService, player.UserId, BadgeID)
if hasBadge then
-- code here (most likely a: .Visible = true/false)
-- There are many ways of getting the Button such as renaming it to the badge ID, setting an attribute, etc.
end
end
The code above is when the player joins the game or the character is loaded; however, if you’d like to update when a player earns a badge, simply set the Button that correlates to the Badge to be visible with the function that awards the player a badge. If you are having troubles with the UI resetting, you can disable ‘ResetOnSpawn.’
Let me know if you have any additional questions, but does this answer your question?