Prevent Tweenservice with CFrames from Rotating back to its original position while moving

Hello Developers, recently I ran into the problem that my model rotates back to its original XYZ orientation when I try to move it with CFrames and tweenservice. It’s not supposed to do that, I want it to walk backwards in that specific angle, is there a way to prevent this from happening?

------------------------------------------------------------ Animation Variables
local anim = Instance.new("Animation")
anim.AnimationId = "rbxassetid://180426354"

local controller = script.Parent.Parent.Humanoid


------------------------------------------------------------

local part = script.Parent

------------------------------------------------------------
local rotationA = 45 
local rotationB = 0

local positionA = 55
local positionB = 0
------------------------------------------------------------
local TweenService = game:GetService("TweenService")
local InfoA = TweenInfo.new(4, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0)
local InfoB = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0)
------------------------------------------------------------

local RotA = {
	CFrame = part.CFrame * CFrame.Angles(0, rotationA, 0)
}

local RotB = {
	CFrame = part.CFrame * CFrame.Angles(0, rotationB, 0)
}


------------------------------------------------------------

local PosA = {
	CFrame = part.CFrame + Vector3.new(0, 0, positionA)
}

local PosB = {
	CFrame = part.CFrame + Vector3.new(0, 0, positionB)
}

------------------------------------------------------------

local TweenRA = TweenService:Create(part, InfoB, RotA)
local TweenRB = TweenService:Create(part, InfoB, RotB)

local TweenPA = TweenService:Create(part, InfoA, PosA)
local TweenPB = TweenService:Create(part, InfoA, PosB)

------------------------------------------------------------ Other Variables
local sign = script.Parent.Parent.Parent.Instructions1.Text.SurfaceGui.SIGN
local world = script.Parent.Parent.Parent


------------------------------------------------------------ Main Function
local anim = controller:LoadAnimation(anim)


------------------ Test section
while true do
	TweenRA:Play()
	wait(2)
	anim:Play()
	TweenPA:Play()
	wait(4)
	anim:Stop()


	secondsElapsed = secondsElapsed + 1

	if secondsElapsed == 6 then
		break
	end
end
local secondsElapsed = 0

------------------

why cant u just change the position and (optionally) orientation in one tween instead of the cframe

for example, in the parameter of the tweens where you need to put in your cframe data, instead you can just do

{Position = position, Orientation = orientation}
and dont include the orientation bit if you don’t want its orientation to change

If I use tweenservice only I won’t be able to weld it, using CFrames fixed it.

you are using cframes for your tweens though are you not?

I am, I think I misunderstood you answer, I am pretty new to coding, would you mind explaining it in further detail?

why is the calculation for rotA and rotB different

Not sure, let me check I think that’s a mistake

I fixed it, but it didn’t fix the problem, but thanks for pointing it out

local RotA = {
Orientation = part.Orientation * CFrame.Angles(0, rotationA, 0)
}

local RotB = {
Orientation = part.Orientation* CFrame.Angles(0, rotationB, 0)
}


local PosA = {
Position = part.Position + Vector3.new(0, 0, positionA)
}

local PosB = {
Position = part.Position + Vector3.new(0, 0, positionB)
}

One more problem, whenever I’m using RotB now, it isn’t rotating back to it’s original position

Nevermind, it somehow fixed itself. I believe it was my studio bugging out. Sorry, but now, how do I fix my main problem?

can you combine them?

local CFrameA = {
Position = part.Position + Vector3.new(0, 0, positionA), Orientation = part.Orientation * CFrame.Angles(0, rotationA, 0)
}

local CFrameB = {
Position = part.Position + Vector3.new(0, 0, positionB), Orientation = part.Orientation* CFrame.Angles(0, rotationB, 0)
}

I can try, give me a few minutes!

It’s giving me an error ‘‘Workspace.Practise1.Dummy.Primary.Script:45: invalid argument #1 (CFrame expected, got Vector3)’’

on what part of the script :heart:

local CFrameA = {
Position = part.Position + Vector3.new(0, 0, positionA), Orientation = part.Orientation * CFrame.Angles(0, rotationA, 0)
}