How to connect a Part that is connected by a motor6d to another part

Sorry the title is confusing, I have a few pictures to show what I mean -

Starts off with a Part that is Connected to a Basepart by Motor6d

Then, The Motor6d is deleted. A new Motor6d is created and connected to a new BasePart. The part stays in the same place.
However, I don’t know how to do this… Please help me!

Motor 6d has properties part0 and part1 use them to achieve your goal.

For example:

local startPart
local part2
local part3

motor6d.Part0 = startPart
motor6d.Part1 = part2
--------------------------------------
motor6d.Part1= part3

I want it to stay in the same place it was before. This will move the part3 to the startPart

Okay I found it

		local w = Instance.new("Motor6D", p1)
		w.Part0 = p1
		w.Part1 = p2
		w.Name = p2.Name
		w.C0 = c0 or p1.CFrame:inverse() * p2.CFrame
		w.C1 = c1 or CFrame.new()
		return w