Lerp Rotation not facing Part

Hello. I’ve got code here that is supposed to face a Part called “Target”

while engineon do
	
	
	local start = script.Parent.Base.Motor6D.C1
	local finish = CFrame.new(script.Parent.Base.Motor6D.C1.Position, Vector3.new(Target.Position.X, script.Parent.Base.Motor6D.C1.Position.Y, Target.Position.Z))

	

	script.Parent.Base.Motor6D.C1 = start:lerp(finish, 0.15)

	
	wait(1/60)
end

Instead it faces away at an angle like this:


The barrel is the front face.

Any idea how to fix?

EDIT 1: Setting a negative makes it move in the correct direction, but it wont face the target.

Sometimes, the part natural forward-facing is offset by 90 degrees, I would try rotating it by another 90 degrees after it faces the part.

1 Like

That’s because C1 is in object-space coordinates. You need to change the coordinate system.

Motor6D.C1 = CFrame.lookAt(basePosition, lookAt):toObjectSpace(Motor6D.Part0.CFrame * Motor6D.C0)
1 Like

I’ve actually got another question. I used the toObjectSpace but instead put the Motor6D.C1 inside the bracket, since I using the Part0 CFrame * Motor6DC0 causes it to be fling. It not stays centered, but it spins eternally.
EDIT 1: Nevermind, i fixed it.