Hats not working on a custom character

I Was working on custom hats for my game and I have noticed an issue in a script (or generally in roblox studio) that when a player equips a hat it will just float above his head.
When I Used the same script that gives you the hat, everything worked just perfectly fine
image

Script I used:

local vest = script.Parent
local handle = vest.Handle
script.Parent.Activated:Connect(function()
	local char = script.Parent.Parent
	local h = script.Parent.Parent.Humanoid
	game.ReplicatedStorage.VestMesh.Parent = char
	h:LoadAnimation(script.Parent.Animation):play()
	h.MaxHealth = 150
	h.Health = 150
	script.Parent:Clone()
	script.Parent:Destroy()
end)

I have tried making the character’s parts not colideable but it didn’t change anything

Have you tried using Humanoid:AddAccessory, if not already?

I Have, it still did not change anything

Can you show me your explorer, what your hat looks like?

the vest is located in replicated storage
image
image

local vest = script.Parent
local handle = vest.Handle
script.Parent.Activated:Connect(function()
	local char = script.Parent.Parent
	local h = script.Parent.Parent.Humanoid
	game.ReplicatedStorage.VestMesh.Parent = char.Torso.BodyFrontAttachment
	h:LoadAnimation(script.Parent.Animation):play()
	h.MaxHealth = 150
	h.Health = 150
	script.Parent:Clone()
	script.Parent:Destroy()
end)

You seem to have parented the accessory to the character, not at the proper attachment, does this work?

but the attachment is inside of the hat not inside of the character

image
The Humanoid’s Torso also has that attachments, which names should match the accessory’s attachment. Roblox will take care of it automatically, as long as these names match. Also, don’t forget to make the accessory unanchored so it doesn’t lock the player.

1 Like

image
it gives me this error

Add a WaitForChild to yield the function until the character loads.

i dont think it really has something to do with the script, i think it is something with the custom character
but i can’t figure out what

I Have noticed that the character can’t sit either

I Solved it by taking some attachments from other characters