A way to convert motor6ds in a keyframesequence

So one of our animators has a habit of welding weapons to the torso. This is good and allows you to move the gun freely. However, due to the game being pretty much used to having weapons welded to the right arm, this causes problems. And I don’t want to force our animator to weld to the right arm.

I’ve been trying out some ways to convert the “Body” motor6d to be welded to the right arm, instead of the torso.

Hierarchy:
grafik

Script:

local KeyframeSequence = game:GetService("Selection"):Get()[1]

local ToConvert = "Body"
local ConvertTo = "Right Arm"

for i,v in pairs(KeyframeSequence:GetChildren()) do
    local s = v:FindFirstChild(ToConvert, true)
    local h = v:FindFirstChild(ConvertTo, true)
    
    local solved = h.CFrame:ToObjectSpace(s.CFrame)
    s.CFrame = solved
    s.Parent = h
end

Result:
grafik