Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to prevent a Model resetting orientation while moving?

Asked by 4 years ago

I'm trying to make a model that goes from its former position to Point 1 then to rotate it and move to Point 2. But when it reaches Point 1 it rotates but, when it starts to move to Point 2 the orientation resets.

Heres how I want the Part to move: https://gyazo.com/619e0dad46ea3daa3f71a8fa6e5e0737

I'm using TweenService to move the model and script.Parent.Torso.CFrame = script.Parent.Torso.CFrame * CFrame.Angles(0,0,0) to rotate the part. Torso is the Primary part of the model.

local TweenService = game:GetService("TweenService")
local Torso = script.Parent:WaitForChild("Torso")
local tweeningInformation = TweenInfo.new(
    7,   
    Enum.EasingStyle.Linear,
    Enum.EasingDirection.Out,
    0,
    false,
    0
)
local tweeningInformation2 = TweenInfo.new(
    3,   
    Enum.EasingStyle.Linear,
    Enum.EasingDirection.Out,
    0,
    false,
    0
)
local Goto1 = {CFrame = CFrame.new(-315.713, 25.511, -20)}
local Goto2 = {CFrame = CFrame.new(-197.713, 25.511, -24)}
local tween1goto = TweenService:Create(Torso,tweeningInformation,Goto1)
local tween2goto = TweenService:Create(Torso,tweeningInformation2,Goto2)

for i = 1,1 do
    wait(5)
    tween1goto:Play()
    wait(7.5)
    script.Parent.Torso.CFrame = script.Parent.Torso.CFrame * CFrame.Angles(0,90,0)
    tween2goto:Play()
end

I'm new to this website and kinda new to scripting.

0
Angles takes radians, you can use math.rad(90) to rotate it 90 degrees, or math.pi/2 since pi radians = 180 degrees User#24403 69 — 4y

Answer this question