Badge not Being Gifted

Hi!
I’m trying to make a badge where you have to trigger a proximity prompt 10 times. I did it 10 times, and I didn’t get the badge. I checked my inventory, and I didn’t have the badge.
Here’s the script:

local prompt = script.Parent.ProximityPrompt
local anim = script.Parent.Animation
local timesPlayed = 0
local badgeserv = game:GetService("BadgeService")
local badgeid = 1183682534100403

prompt.Triggered:Connect(function(player)
	local hum = player.Character:WaitForChild("Humanoid")
	local loadanim = hum.Animator:LoadAnimation(anim)
	
	loadanim:Play()
	
	hum.AutoRotate = false
	hum.WalkSpeed = 0
	wait(3.35)
	loadanim:Stop()
	
	hum.AutoRotate = true
	hum.WalkSpeed = 16
	
	timesPlayed = timesPlayed + 1
end)

if timesPlayed == 10 then
	local player = game.Players:GetPlayerFromCharacter(timesPlayed.Parent)
	badgeserv:AwardBadge(player.UserId,badgeid)
end

Can someone help?

1 Like

You may have already accidently given yourself the badge therefore you can’t get it again. Try it again on an alt to see if that works.

2 Likes

So I tried on an alt, and I still didn’t get the badge.

1 Like

Try this script get badge on a part when touch or click

local badgeId = YOUR_BADGE_ID_HERE
local BadgeService = game:GetService(“BadgeService”)

script.Parent.Activated:Connect(function(player)
if not BadgeService:UserHasBadgeAsync(player.UserId, badgeId) then
BadgeService:AwardBadge(player.UserId, badgeId)
print(player.Name … " earned the badge!")
end
end)

try and put your badge id in the script
Try if this is helpful

1 Like

Ok I’ll try it. Hopefully this works.

1 Like

I think i see why

and

I don’t think the character is equal to 0.parent

If this is a local script then just get the player from

local player = game.Players.LocalPlayer
1 Like

Might work too Awdiow
you know scripts nahhh bro on the next level
im a basic scripter ):
i have.\ idk

1 Like

so am I. I started like last year.

1 Like

Oh try this:

local prompt = script.Parent.ProximityPrompt
local anim = script.Parent.Animation
local timesPlayed = 0
local badgeserv = game:GetService("BadgeService")
local badgeid = 1183682534100403

prompt.Triggered:Connect(function(player)
	local hum = player.Character:WaitForChild("Humanoid")
	local loadanim = hum.Animator:LoadAnimation(anim)
	
	loadanim:Play()
	
	hum.AutoRotate = false
	hum.WalkSpeed = 0
	wait(3.35)
	loadanim:Stop()
	
	hum.AutoRotate = true
	hum.WalkSpeed = 16
	
	timesPlayed = timesPlayed + 1

    if timesPlayed == 10 then
	    badgeserv:AwardBadge(player.UserId,badgeid)
    end
end)

2 Likes

Same 1 year on script and build model and uis

2 Likes

Just replace the part where you say

with

1 Like

Issue is when server already reads code and after you trigger it would not run code again so that is error.

2 Likes

Oh sorry i just copy&pasted code this should definetly work.

4 Likes

Yea that should be it the timesPlayed check should be in the triggered event code

4 Likes

i guess some people know more than my smart ahh brain

2 Likes

Is not problem is its already read

if timesPlayed == 10 then
	local player = game.Players:GetPlayerFromCharacter(timesPlayed.Parent)
	badgeserv:AwardBadge(player.UserId,badgeid)
end

so it would not read again when proximtly promot is triggered it would only read proximtly prompt function and also timesPlayed is boolen not Instance

1 Like

yeah my bad I realized in the actual beginning code the if statement wasn’t in the function

2 Likes

its ok, everyone makes mistakes

1 Like

Since you removed the local player = game.Players.LocalPlayers I thought it wasn’t gonna work but it worked. Ty!

1 Like

Haven’t done uis but I’ve done scripting and building

1 Like