Badge not awarding on click even if output prints it out as successful

I seem to not be able to get the game to award the badge to the player upon finding a specific easter egg. When you click on this hidden object, you’re supposed to have the badge go into your inventory.
However, I got my two friends and one of my alt accounts without the badge to test it out, and they seem to not be able to get the badge even after the intended interaction with said object.

Here’s the script:

local BadgeService = game:GetService("BadgeService")

local badgeId = 2128678903

local clickdetector = script.Parent

clickdetector.MouseClick:Connect(function(plr)

local hasBadge = BadgeService:UserHasBadgeAsync(plr.UserId, badgeId)

if hasBadge then

print(plr.Name .. "Already owns the badge.")

else

BadgeService:AwardBadge(plr.UserId, badgeId)

end

print("Good Grief.")

end)

This will print even if it doesnt award the badge… for it to print when it awards the badge you will have to move the print statement like so:

local BadgeService = game:GetService("BadgeService")

local badgeId = 2830818688

local clickdetector = script.Parent

clickdetector.MouseClick:Connect(function(plr)

local hasBadge = BadgeService:UserHasBadgeAsync(plr.UserId, badgeId)

if hasBadge then

print(plr.Name .. "Already owns the badge.")

else

BadgeService:AwardBadge(plr.UserId, badgeId)

print("Good Grief.")

end


end)
1 Like

This was a helpful tip, thanks.
but I figured out it was the wrong ID I mistakenly put there. I will make sure to keep in mind your advice though, better to walk out with something than nothing.

1 Like