Badge Giver not working

Hey, so today I uploaded some new badges for my game and one of the badges would just be touching an object and you’ll receive it. So I used the classic badge giver script that Roblox would give you when you first uploaded a badge, However this does not work anymore. It’s been years uploading a badge and I’m just curious if anything changed or not, I’ll leave the script down below if anyone wants to just correct it for me or tell me what to do that’d be great. Thanks.

`print("Badge Awarder Loaded. BadgeID: " .. script.Parent.BadgeID.Value)```





function OnTouch(part)
	if (part.Parent:FindFirstChild("Humanoid") ~= nil) then
		local p = game.Players:GetPlayerFromCharacter(part.Parent)
		if (p ~= nil) then
			print("Awarding BadgeID: " ..script.Parent.BadgeID.Value .. " to UserID: " .. p.userId)
			local b = game:GetService("BadgeService")
			b:AwardBadge(p.userId, script.Parent.BadgeID.Value)
		end
	end
end
1 Like

What errors are you getting if any?

None, whenever touching the badge I get no errors

Is this the full script of it?

If yes, because you didn’t call the function that’s why it didn’t execute.

This maybe works:

function OnTouch(part)
	if (part.Parent:FindFirstChild("Humanoid") ~= nil) then
		local p = game.Players:GetPlayerFromCharacter(part.Parent)
		if (p ~= nil) then
			print("Awarding BadgeID: " ..script.Parent.BadgeID.Value .. " to UserID: " .. p.userId)
			local b = game:GetService("BadgeService")
			b:AwardBadge(p.userId, script.Parent.BadgeID.Value)
		end
	end
end

script.Parent.Touched:Connect(OnTouch)
--I used script.Parent if the script is inside of the part.
2 Likes