How to Rotate Motor6D to look at a target?


Goal is the get the upper part of the turret to rotate towards a target… I am using the part seen as the test subject.

Airship - Roblox Studio
As you can see, I set up the turret correctly, and here I just rotate the C0 of the motor6d by a constant.


But when I actually run the CFrame.lookAt() Code, it just tps part of it to a random location in the middle of no where…

Here is my code:

function BeetleMortar:SwivelTowardsTarget()

	local Target = game.Workspace.PositionParttt
	local SwivelJoint = self.Swivel

	if not SwivelJoint or not Target then return end

	local initialC0 = SwivelJoint.C0

	local Connection = RunService.Heartbeat:Connect(function(DeltaTime)
		if not SwivelJoint or not Target then return end

		local turretPosition = SwivelJoint.Parent.Parent:FindFirstChild("Shell").Position
		local targetPosition = Target.Position

		local targetCFrame = CFrame.lookAt(turretPosition, targetPosition)

	--	SwivelJoint.C0 = SwivelJoint.C0 * CFrame.Angles(0, math.rad(10), 0)
		SwivelJoint.C0 = targetCFrame
	end)

	-- Store connection for cleanup later
	if self.OpenConnections then
		table.insert(self.OpenConnections, Connection)
	end

end

Ultimately, the goal will be to lerp the orientation to look at the target, but I just have not been able to do that…Also if it helps, here is the hierarchy of the model:

Capture

Any info is appreciated! Thanks in advance!