Basically The model/hat instead of going on my head its inside my head
So I tried to look up the problem but instead i got this script where now the hat instead
of being inside my head its perfectly where it has to be but upside down???
Images
With script
Without script just the attachment
Script
function weldAttachments(attach1, attach2)
local weld = Instance.new(“Weld”)
weld.Part0 = attach1.Parent
weld.Part1 = attach2.Parent
weld.C0 = attach1.CFrame
weld.C1 = attach2.CFrame
weld.Parent = attach1.Parent
return weld
endlocal function buildWeld(weldName, parent, part0, part1, c0, c1)
local weld = Instance.new(“Weld”)
weld.Name = weldName
weld.Part0 = part0
weld.Part1 = part1
weld.C0 = c0
weld.C1 = c1
weld.Parent = parent
return weld
endlocal function findFirstMatchingAttachment(model, name)
for _, child in pairs(model:GetChildren()) do
if child:IsA(“Attachment”) and child.Name == name then
return child
elseif not child:IsA(“Accoutrement”) and not child:IsA(“Tool”) then – Don’t look in hats or tools in the character
local foundAttachment = findFirstMatchingAttachment(child, name)
if foundAttachment then
return foundAttachment
end
end
end
endfunction addAccoutrement(character, accoutrement)
accoutrement.Parent = character
local handle = accoutrement:FindFirstChild(“Handle”)
if handle then
local accoutrementAttachment = handle:FindFirstChildOfClass(“Attachment”)
if accoutrementAttachment then
local characterAttachment = findFirstMatchingAttachment(character, accoutrementAttachment.Name)
if characterAttachment then
weldAttachments(characterAttachment, accoutrementAttachment)
end
else
local head = character:FindFirstChild(“Head”)
if head then
local attachmentCFrame = CFrame.new(0, 0.5, 0)
local hatCFrame = accoutrement.AttachmentPoint
buildWeld(“HeadWeld”, head, head, handle, attachmentCFrame, hatCFrame)
end
end
end
end