Having trouble scripting a animated sword with the Rig

I’m working on scripting my animated sword when I equip it pressing E. It is originally welded to the sheath on my side, and then I welded it to my hand once I pressed E. I’m a bit new to Motor6D’s so please help!

The problem is I the sword’s animation Isn’t playing how its suppose to. Its still like welded to the arm and not doing it’s own animation.
image

How can I fix this?
Video:Motor6D not working - YouTube

	RightHandle.Parent = Character
					
					local Weld = Instance.new("WeldConstraint")
					Weld.Part0 = RightHandle
					
					if Humanoid.RigType == Enum.HumanoidRigType.R15 then
						
						Weld.Part1 = Character:WaitForChild("RightHand")

					elseif Humanoid.RigType == Enum.HumanoidRigType.R6 then 
						
						Weld.Part1 = Character:WaitForChild("Right Arm")
						
					end
					
					Weld.Parent = Weld.Part0
					
					
					SwordMain:PivotTo(RightHandle.CFrame)
					
					local Motor6D = Instance.new("Motor6D")
					
					Motor6D.Part0 = SwordMain.PrimaryPart
					Motor6D.Part1 = RightHandle
					Motor6D.C0 = Motor6D.Part0.CFrame:ToObjectSpace(Motor6D.Part1.CFrame)
					Motor6D.Parent = Motor6D.Part0
					print("Motor6D")```