What is wrong with this script? I'm trying to make it so when you click the hat it gives you it on your head, I've been trying for hours, whats wrong?
function onClicked()
--code
if onClicked(PlayerWhoClicked) then
h = Instance.new("Hat")
p = Instance.new("Part")
h.Name = "Headphones"
p.Parent = h
p.Position = hit.Parent:findFirstChild("Head").Position
p.Name = "Handle"
p.formFactor = 0
p.Size = Vector3.new(2, 1, 1)
p.BottomSurface = 0
p.TopSurface = 0
p.Locked = true
script.Parent.Mesh:clone().Parent = p
h.Parent = hit.Parent
h.AttachmentPos = Vector3.new(0, 0.3, 0)
wait(5)
debounce = true
end
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)

3 comments
Didn't work.
Oh I see, on line 13 change it to this: p.CFrame = CFrame.new(char:findFirstChild("Head").CFrame.p)
Still didn't work.