Motor6D Part Position Issue

My problem;
The part that is supposed to rotate moves inside the part that it is welded too. Why does it do that?
I used a motor6d.

Before;
https://gyazo.com/6d8916c2042dd5d703b777012a594d16

After;
https://gyazo.com/28d705637ff00611ad08d0d68349b55b

Code;

 print('WELDINGGGGG USING MOTOR6D')

local part = script.Parent.yTest
local part2 = script.Parent.xTest


local a = Instance.new('Motor6D')
a.Parent = part
a.Part0 = part2
a.Part1 = part

while true do
wait()
  a.C0 = a.C0 * CFrame.Angles(0,math.rad(5),0)
 end

EDIT: Corrected the before image.

If the Part1 is un-anchored, the weld automatically sets Part1’s position to Part0’s position.

Is it possible to keep Part1’s position, without anchoring it?

Try replacing

a.Part0 = part2
a.Part1 = part

with

a.Part0 = part
a.Part1 = part2

Edit: Which part is yTest and which xTest?

yTest is the part that is going to rotate. xTest is the part that is the “base”. I switched the Part0 and Part1, but the results are the exact same as previous.

I have found a solution, you can add a ‘SpecialMesh’ to the ‘xTest’ Part and change the ‘MeshType’ to brick alongside with changing the ‘y Offset’ of the ‘SpecialMesh’ to something close to 5.

Yes, but I’d like to keep the base still. Imagine the base is a tank, and the part I’m trying to rotate is the turret. That’s what I’m trying to do, so I can’t move the base.

Solved it. Turns out I have to set the C0/C1 values first. Here’s the working code.

print('WELDINGGGGG USING MOTOR6D')

local part = script.Parent.yTest
local part2 = script.Parent.xTest


local a = Instance.new('Motor6D')
a.Parent = part
a.C0 = part2.CFrame:Inverse() * part.CFrame
a.Part0 = part2
a.Part1 = part


while true do
wait()
    a.C0 = a.C0 * CFrame.Angles(0,math.rad(5),0)
end
1 Like