Tweened CFrame not Properly Adjusting Orientation

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I wish to orient and move an object to match the location and orientation of a different object using TweenService.

  2. What is the issue? Include screenshots / videos if possible!
    Upon completion of the second tween, the translucent black part (Part1) shown in the following video does not have the same orientation as the second grey part (Part3), as it is meant to.
    robloxapp-20210706-1440188.wmv (224.1 KB)

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I was unable to find any issues with the code, so I have not been able to test any solutions yet. I searched for similar issues on the Developer Forum, but I was unable to find any solution (I also reviewed CFrame and TweenService articles on the Developer Hub).

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

Below is the script that tweens the CFrame of the translucent black object in the above video:

local TweenService = game:GetService("TweenService")

local object = script.Parent
local goal = {}
goal.CFrame = CFrame.new(game.Workspace.Part2.Position.X, game.Workspace.Part2.Position.Y, game.Workspace.Part2.Position.Z) * CFrame.Angles(math.rad(game.Workspace.Part2.Orientation.X), math.rad(game.Workspace.Part2.Orientation.Y), math.rad(game.Workspace.Part2.Orientation.Z))
local tweenInfo = TweenInfo.new(2.5, Enum.EasingStyle.Quad)
local tween = TweenService:Create(object, tweenInfo, goal)
wait(2)
tween:Play()
tween.Completed:Wait()

goal = {}
goal.CFrame = CFrame.new(game.Workspace.Part3.Position.X, game.Workspace.Part3.Position.Y, game.Workspace.Part3.Position.Z) * CFrame.Angles(math.rad(game.Workspace.Part3.Orientation.X), math.rad(game.Workspace.Part3.Orientation.Y), math.rad(game.Workspace.Part3.Orientation.Z))
tweenInfo = TweenInfo.new(2.5, Enum.EasingStyle.Quad)
tween = TweenService:Create(object, tweenInfo, goal)
tween:Play()

A copy of the place file can be found here:
Test_Place.rbxl (22.9 KB)

Let me understand better.
Do you wish Part1 (black) to start from the Part2.Position/Orientation and stop at Part3.Position/Orientation?
If so, you need only one Tween.

local TweenService = game:GetService("TweenService")
local object = script.Parent
object.CFrame = game.Workspace.Part2.CFrame
wait(3)
local goal = {CFrame = game.Workspace.Part3.CFrame}
local tweenInfo = TweenInfo.new(2.5, Enum.EasingStyle.Quad)
local tween = TweenService:Create(object, tweenInfo, goal)
tween:Play()
tween.Completed:Wait()

No, sorry, I would like Part1 to start at its current location. The problem I’m having is that the second Tween is not rotating the part correctly.

np, however, a second tween before my example, from the current Part1.Cframe to Part2.CFrame and then the same for Part3.
Maybe your problem has to do with face alignment.

I have verified that the Part2 and Part3 are oriented correctly, but nothing seems to have changed.

The concept of tween is very simple: it takes the CURRENT value of the object and transforms it into the final value (goal) you want. In your case, tween:Play will use the current Cframe of Part1 and move to the desired destination. The Cframe already takes care of adjusting both position and orientation at once.

But I don’t know if I understood correctly what you want.
In any case, I suggest you try it step by step.

With all due respect, I understand how tween works; the issue is simply that upon completion of the
second tween, Part1 does not have the same orientation as Part3, as it is meant to.

Sorry for not being able to help you with something that should be simple because then I didn’t really understand the problem.
If you rephrase the question in another way, maybe more people can collaborate.

I’ve edited the topic, particularly the portion where I attempt to explain the issue, to be much more concise (and hopefully more helpful).

1 Like

I think you didn’t test my first example, because if you see there, Part1 and Part3 are matching:

Your code:

My code:

And here if make 2 tweens, as I said before:

local TweenService = game:GetService("TweenService")
local object = script.Parent
wait(3)
local goal = {CFrame = game.Workspace.Part2.CFrame}
local tweenInfo = TweenInfo.new(2.5, Enum.EasingStyle.Quad)
local tween = TweenService:Create(object, tweenInfo, goal)
tween:Play()
tween.Completed:Wait()

wait(3)
local goal = {CFrame = game.Workspace.Part3.CFrame}
local tweenInfo = TweenInfo.new(2.5, Enum.EasingStyle.Quad)
local tween = TweenService:Create(object, tweenInfo, goal)
tween:Play()
tween.Completed:Wait()

a

I’m very sorry, I hadn’t really read the code you wrote, thinking it was just the second tween entirely unedited, which was rather foolish of me.