So basically, once you click on the hat it should give you it, but with face accessory, it put it on the wrong spot (Such as above the head or behind), how do I make it work for a face accessory?

local AttachmentPos = Vector3.new(0, -0.24, -0.45)







debounce = true

function onTouched(hit)
		debounce = false
		h = Instance.new("Hat")
		p = Instance.new("Part")
		h.Name = "Hat"   -- It doesn't make a difference, but if you want to make your place in Explorer neater, change this to the name of your hat.
		p.Parent = h
		p.Position = hit.Character:findFirstChild("Hat").Position
		p.Name = "Handle" 
		p.formFactor = 0
		p.Size = Vector3.new(-0,-0,-1) 
		p.BottomSurface = 0 
		p.TopSurface = 0 
		p.Locked = true 
		script.Parent.Mesh:clone().Parent = p
		h.Parent = hit.Character
		h.AttachmentPos = AttachmentPos -- Change these to change the positiones of your hat, as I said earlier.
		wait(5)		debounce = true
	end

script.Parent.ClickDetector.MouseClick:connect(onTouched)

Much love, Ber_ries.

2 comments

0

Make sure you create an Instance of Accessory. Not 'Hat'.

0

:findFirstChild() and :connect() are deprecated.