I am trying to make a badge when you touch it you get a badge.
I have tried to do it but it dosent work, could anyone help?
I am trying to make a badge when you touch it you get a badge.
I have tried to do it but it dosent work, could anyone help?
You could do something like this:
local BadgeService = game:GetService("BadgeService")
local badgeID = 319283391293
part.Touched:Connect(function(object)
local player = game.Players:GetPlayerFromCharacter(object.Parent)
if player then
local success, errorMessage = pcall(function()
BadgeService:AwardBadge(player.UserId, badgeID)
end)
if not success then
-- THis code will run if the badge awarding failed maybe tell the player to touch the part again.
end
end
end)
Just replace part with whatever part you want
EDIT: just updated the script to include a pcall around the AwardBage function in case it fails
I will try it out, thanks you, I hope it works!
For some reason badges in my game dosent work, when I try multiple ways that worked before it dosent work, do you know what the problem is?
Is nothing at all happening or is there an error in the output?
I have no idea, do you think you could help me in studio?
Lets move this to DMs. I will DM you.
Please remember to post the problem and solution once you’ve found it. Everyone has the experience of looking through a thread about their problem only for it to end like that. Best not increment people’s counts. Thanks for providing help, though!
Oh sorry completely forgot it was in fact the solution above.