Howdy DevForum Members! I have a question. How would I make a UI appear to a player that owns this specific badge. I have seen it in multiple games before such as R6 Dances.
I would recommend having a look at the documentation.
BadgeService:UserHasBadgeAsync()
This function allows you to check if the user has a badge or not, as it returns a boolean (true or false).
Works under two conditions if you saw the page:
1. Must be called from a server-side Script or a ModuleScript that gets required eventually
2. The player has to actively be in the server.
It’s one of those functions where it is recommended you wrap it in a pcall as it is prone to error.
This sample of code was taken from the website:
-- Check if the player has the badge
local success, hasBadge = pcall(function()
return 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!")
return
end
if hasBadge then
-- Handle player's badge ownership as needed
end
Next time, please actually try searching first using your search engine. The probability of questions like these being solved quicker are much higher if you do your own research first.
1. Only works on a local script
Where did you get that from?
On the docs, it says:
This function must be called from a server-side Script or a ModuleScript eventually required by a Script, not from a LocalScript.
My bad, I’ll change that real quick.