Script Won't Give Achievement

I have a part that makes it so you should receive a badge when you touch it, however it does not appear to be working. I have tested it multiple times to no success. It is listed below, as well as the badge.

local badgeservice = game:GetService("BadgeService")
local id = (2127621157) --put badge id here

script.Parent.Touched:Connect(function(hit)

	if hit.Parent:FindFirstChild("Humanoid")then

		local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
		badgeservice:AwardBadge(plr.UserId,id)
	end
end)

The badge ID is 2127621157, same as in script.

Try this

local Players = game:GetService("Players") -- gets player service
local badgeservice = game:GetService("BadgeService")
local id = 2127621157 --put badge id here

script.Parent.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		local plr = Players:GetPlayerFromCharacter(hit.Parent)
		if not badgeservice:UserHasBadgeAsync(plr.UserId, id) then -- only award the badge if the player does not own it
			badgeservice:AwardBadge(plr.UserId, id)
		end
	end
end)

Have you tested it in game?

it should be

2127621157

and not

(2127621157)

badges may not work in studio

1 Like

Did you test in studio or in the actual game?