Manually calculating orientation

Hello! So my goal is to take part A and point it towards point B. The catch here is I want to do it without manually setting the cframe or a tween goal. I want to approach it with the idea of “This is what I have to add to orientation X,Y,Z in order to reach the goal orientation”. I want it broke up into 2 ideas. I need to tilt UP/DOWN and LEFT/RIGHT.


The code I currently have is below. I think the issue I am running into is once an angle exceeds > 90 all the other angles have to be inverted to 180. Not exactly sure.

local Ship = script.Parent

local function closestRock()
	local Closest = nil
	local closestDistance = math.huge
	
	for i,v in pairs(workspace:GetChildren()) do
		if v.Name == "Rock" then
			if (Ship.Position - v.Position).magnitude < closestDistance then
				Closest = v
				closestDistance = (Ship.Position - v.Position).magnitude
			end
		end
	end
	
	return Closest
end

while wait() do
	local Rock = closestRock()
	
	if Rock then
		while Rock.Parent do
			local directionalCFrame = CFrame.new(Ship.Position,Rock.Position)
			
			local orientPart = Instance.new("Part")
			orientPart.CFrame = directionalCFrame
			orientPart.Transparency = .7
			orientPart.Parent = Ship
			orientPart.Anchored = true
			orientPart.CanCollide = false
			orientPart.Size = Vector3.new(2,2,3)
			
			local goalX,goalY,goalZ = orientPart.Orientation.X,orientPart.Orientation.Y,orientPart.Orientation.Z
			local currentX,currentY,currentZ = Ship.CFrame:ToEulerAnglesXYZ()
			
			local diffX,diffY,diffZ = goalX-currentX,goalY-currentY,goalZ-currentZ
			
			if diffX < -.15 then
				Ship.Orientation = Ship.Orientation + Vector3.new(-.1,0,0)
			elseif diffX > .15 then
				Ship.Orientation = Ship.Orientation + Vector3.new(.1,0,0)
			end
			
			print(diffX)			
			
			game:GetService("RunService").Stepped:Wait()
			orientPart:Destroy()
		end
	end
end

is there a reason you don’t want to just tween the cframe to CFrame.new(Position, LookAt)?

Yes because the idea is to get a set of instructions necessary to reach the required goal

You could use CFrame:Lerp().

https://developer.roblox.com/en-us/api-reference/datatype/CFrame\

Solved the problem myself, no need to comment guys!