Hat Giver Issue: Backwards Equipping Problem

Hello, I’m currently working on a game that features hat givers, and the hats in the game are UGC items from the catalog. I’ve used this specific hat giver in all my previous games without any issues, but I’ve encountered a problem with it.

Here’s the issue: when players equip the hat, it appears to be equipped backwards. I’ve tried a common fix, like rotating the item in studio, but unfortunately, I haven’t been able to resolve the problem.

code for it:


function onTouched(hit)
	if (hit.Parent:findFirstChild("Humanoid") ~= nil and debounce == true) then
		debounce = false
		h = Instance.new("Hat")
		p = Instance.new("Part")
		h.Name = "HoodedAssassin"
		p.Parent = h
		p.Position = hit.Parent:findFirstChild("Head").Position
		p.Name = "Handle" 
		p.formFactor = 0
		p.Size = Vector3.new(1, 0.4, 1) 
		p.BottomSurface = 0 
		p.TopSurface = 0 
		p.Locked = true 
		script.Parent.SpecialMesh:clone().Parent = p
		h.Parent = hit.Parent
		h.AttachmentForward = Vector3.new (0, 0, 0)
		h.AttachmentPos = Vector3.new(0, 0.4, -0.19)
		h.AttachmentRight = Vector3.new (1, 0, 0)
		h.AttachmentUp = Vector3.new (0, 1, 0)
		wait(5)
		debounce = true
	end
end```

script.Parent.Touched:connect(onTouched)

I would greatly appreciate if someone had the fix for this. Thank you

3 Likes

I would try doing…

p.CFrame = hit.Parent.Head.CFrame

instead of…

p.Position = hit.Parent:findFirstChild("Head").Position

Also, I would check if the player has a head in the conditional statement above since FindFirstChild doesn’t guarantee that the character will have a head.

1 Like

I advise against setting these. You should set the CFrame property instead.

1 Like


function onTouched(hit)
	if (hit.Parent:findFirstChild("Humanoid") ~= nil and debounce == true) then
		debounce = false
		h = Instance.new("Hat")
		p = Instance.new("Part")
		h.Name = "HoodedAssassin"
		p.Parent = h
		p.CFrame = hit.Parent.Head.CFrame
		p.Name = "Handle" 
		p.formFactor = 0
		p.Size = Vector3.new(1, 0.4, 1) 
		p.BottomSurface = 0 
		p.TopSurface = 0 
		p.Locked = true 
		script.Parent.SpecialMesh:clone().Parent = p
		h.Parent = hit.Parent
		h.Attachment.CFrame = CFrame.new(Vector3.new(0, 0.4, -0.19))
		h.Attachment.CFrame = CFrame.new(Vector3.new(0, 0, 0))
		h.Attachment.CFrame = CFrame.new(Vector3.new(1, 0, 0))
		h.Attachment.CFrame = CFrame.new(Vector3.new(0, 1, 0))
		wait(5)
		debounce = true
	end
end

script.Parent.Touched:connect(onTouched)
2 Likes

Hm, it must not be the issue. Does it work if you have a blank rig in the starter character?

2 Likes

Yea, it faces the correct way when I put it onto a rig. not sure what it could be

2 Likes

using these ugc items

1 Like

Is there a reason you can’t just use the normal FaceFrontAttachment inside of the hat and add it via humanoid:AddAccessory()?

Hats are also deprecated, use accessories instead.

1 Like

Nope, haven’t tried that yet.

elaborate ?