How to Equip Hats onto Non-Humanoids?

I have this noob head and I want to make it so that hats automatically get put on it through a script. image
The problem is that there is no humanoid so I cannot use the :AddAccessory() function. I was wondering if I could use the attachment inside of the hat to help position it but it doesn’t seem like there’s much in there. The noob head won’t move so a weld will not be needed.

I found out that if I change the position of the attachment the hat will move, but this only works in a regular character and not in the noob head.

I was wondering if there’s any way to position the hats onto the noob head as if it would be positioned on a regular player.

1 Like

could you make a fake AccessoryWeld and weld the hat to the noob and then tweak C0/C1 from there?

1 Like

Just a random item from the catalog:
image
See the FaceFrontAttachment? Now we have to figure out a way to find that attachment in a traditional character and align it
(I assume you wont be dealing with pieces that attach to anything but the head)
Here’s example code that strictly applies to this case (might have different attachments for different hats)
Here’s values for FaceFrontAttachment:
image
You’ll want to store the CFrames for each possible hat attachment somewhere
-Assume we have variables head and hat, you want the hat to be placed on the head
-Also assume we have access to the facefrontattachment’s CFrame, in the form of faceFrontCFrame
Logically, what we want is hat.Handle.FaceFrontAttachment.CFrame = head.CFrame * faceFrontCFrame
Basic matrix algebra, multiply both sides by the handle attachment CFrame inverse so we know where to place the handle itself

hat.Handle.CFrame = hat.Handle.FaceFrontAttachment.CFrame:Inverse() * head.CFrame * faceFrontCFrame

That’s it! I tried explaining all the ins and outs of it so you could expand it into a system that would work for all types of hats.

6 Likes

This is what I tried and it positioned it incorrectly.

obj.Parent = game.Workspace.Dummy
wait(0.5)
local cframe = obj.Handle:FindFirstChildOfClass("Attachment").CFrame
obj.Parent = noob	
obj.Handle.CFrame = obj.Handle:FindFirstChildOfClass("Attachment").CFrame:Inverse() * noob.Main.CFrame * cframe

I parented it to a regular humanoid then I saved the CFrame of the attachment when it was equipped and then I changed the parent and used your formula to position it. What did I do wrong here?

I just used your logic and made a solution that suits my needs.

What I did is I equipped it to a humanoid and I saved the difference between the positions:
local position = (obj.Handle.Position - game.Workspace.Dummy.Head.Position)

I then used the saved difference and added it to the new head:
obj.Handle.CFrame = noob.PrimaryPart.CFrame * CFrame.new(cframe)

I think your code would’ve done something like this but I am a big cframe noob and I probably put in the wrong value.