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
------------------