Need help tweening Orientation to look at object

As title said, I want to tween the orientation of a part, however, from my understanding, Orientation needs a Vector3 value
CFrame.lookAt(pos1, pos2):ToOrientation gives one but it is described in Z Y X order
Even then, the error that arrives is that given type from ToOrientation is a ‘double’

Am I missing something? Is there a slight mistake?
Or should I approach this differently?

local partPos = part.Position
local object = MainBody
local info = TweenInfo.new(3, Enum.EasingStyle.Circular, Enum.EasingDirection.Out, 0, false, 0)
local ptable = {Orientation = CFrame.lookAt(MainBody.Position, partPos):ToOrientation()}

TweenService:Create(object, info, ptable):Play()
2 Likes

U can just

CFrame = CFrame.lookAt(MainBody.Position, playerHeadPos)

also what is the playerHeadPos variable

1 Like

My bad about the variable mishap
As for the solution, my experience simply using CFrame is that it locks the object I want to tween in place, now looking back I feel like I should’ve specified that the object I want to be tweening will also be moving and will need to ‘track’ the player
Yet for a smoother rotation I had the idea of using tweens

1 Like

Oh so it’s always gonna be looking at the player?

You should be using RunService for that

local runS = game:GetService("RunService")
local partPos = part.Position
local object = MainBody

runS.RenderStepped:Connect(function(Delta)
   object.CFrame = object.CFrame:Lerp(CFrame.lookAt(MainBody.Position, partPos), Delta*5)
end)
2 Likes

Thank you so much!
I really should use Lerp much more
Not only did this make it way simpler but also gave me exactly the type of tracking I wanted.
I appreciate it a lot man, have a good one.

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.