Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

I tried making it so if you touch a part, you would get a badge but it doesnt work, how do i fix it?

This is my code:

local badgeId = 38380038 script.Parent.Touched:Connect(function(hit)

	if hit.Parent:FindFirstChild("Humanoid")

	local BadgeService = game:GetService("BadgeService")

	local function awardBadge(player, badgeId)
		if BadgeService:IsLegal(badgeId) and not BadgeService:IsDisabled(badgeId) then
			BadgeService:AwardBadge(player.UserId, badgeId)
		end
	end
end

What did i do wrong?

1 answer

This might be confusing problem I ever seen. You added IsLegal (Which is Deprecated), so it won't work that way. Instead, use this:

local id = 0 -- Put your badge here.

local function onTouched(hit)
	local player = game.Players:GetPlayerFromCharacter(hit.Parent)
	local BadgeService = game:GetService("BadgeService")
	
	BadgeService:AwardBadge(player.UserId, id)
end

script.Parent.Touched:Connect(onTouched)

This discussion is preserved as it was. New answers, comments, and votes are closed.