Fixing hats onto non-humanoid objects

I made this game where you are a ball and roll around, ive been trying to set the hat’s position correctly on the ball, yet some hats dont stay where they should.

Like this hat, which should stay completely in the ball
since it looks like this on the normal avatar
but it doesnt, and i dont know the reason why.

part of the script which makes the hat fixate to the right position:

part:PivotTo(part:FindFirstChildOfClass("Attachment").CFrame:Inverse() * character.CFrame * character.HatAttachment.CFrame)

Any help would be appreciated, thank you.
i have tried for hours on end now to fix this.

1 Like