Badge giving problem

ok. im guessing its not working because the badges are badges of a game made by my group i just don’t know why its not giving it to me on published version and in play test, this my scripts

I tried doing a touch part didn’t work.

script.Parent.Touched:Connect(function(part)
	if part.Parent:FindFirstChild("Humanoid") then
		local player = game.Players:GetPlayerFromCharacter(part.Parent)
		game:GetService("BadgeService"):AwardBadge(player.UserId, 2127099263) -- Put your badge id
	end
end)

Then I tried clicking on it, didn’t work.

script.Parent.ClickDetector.MouseClick:Connect(function(plr)
	if plr.adminpass.Value == false then
		plr.adminpass.Value = true
		local badgeservice = game:GetService("BadgeService")
		local badge = 2127098172

		local HasBadge = badgeservice:UserHasBadgeAsync(plr.UserId, badge)

		if HasBadge then
		else
			badgeservice:AwardBadge(plr.UserId, badge)
		end
	end
end)

SO I HAVE 0 CLUE WHAT IS GOING ON

you should use pcalls to prevent errors

1 Like

Look at BadgeService:AwardBadge()'s code sample at the bottom of the page to fix up your code.

1 Like

nevermind it works it just wasn’t working in studio for some reason

But you should use pcalls generally to avoid errors. It’s also good practice.

1 Like

how would that cause errors???

I never said it would. I’m saying if errors were to arise, then yes, it would help to have pcalls in place.

but it didn’t have errors in the first place

Dude, if you don’t want feedback, don’t respond to my messages. :rofl:

You’re overthinking, just say thanks and move on.

1 Like

Plus, roblox’s services may go down, and you’ll be stuck.

1 Like

No problem. :heart:

why you said no problem???

Because I wish to. Problem?

Not any of your business. Also, if you have a problem, deal with it silently.

why do you keep replying don’t you have something better to do as a “developer”

No, I honestly don’t because I’m bored. Just seeing how fun it is to help out new people tho.

ok then go help then and stop replying lmao

I did just help someone new (yourself), thank you for letting me do so. It’s been quite fun. Now I will stop replying.

yeah but im not new? and you didn’t help me because i briefly discovered the script worked just not testing in studio