I used this function when creating code to attach an accessory to a character’s hand locally.
attach1 is the character’s RightGripAttachment, and attach2 is the accessory’s attachment. I understand welds in general, but I don’t understand why setting the weld’s C0 to the first attachment’s CFrame and C1 to the second attachment’s CFrame makes the accessory oriented correctly.
Could someone please give an explanation? (I don’t understand CFrame maths much)
local 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
end
Thanks!