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

Brick Tween Rotations Reset To (0, 0, 0)?

Asked by 7 years ago
Edited 7 years ago

So, I've been trying to fix this problem for hours and I can't seem to find the solution.

Whenever you have a brick that doesn't have the orientation of (0, 0, 0), as it travels along a tween:Play(), it will rotate during the process and end with (0, 0, 0).

I have a train mesh part and in-order for it to face the way i want it to travel, it's orientation is (0, -90, 0). And, of course, as it tweens... it turns slowly off the track and ends the tween back at (0, 0, 0).

Is there a way that I can have my train at the orientation (0, -90, 0), and have it end the tween at (0, -90, 0)?

local TweenService = game:GetService("TweenService")
local Train = script.Parent.MovingTrain:WaitForChild("Train")

Train.Start.Value = Train.Position --This sets a position to reset the train after it finishes

local endTrain = script.Parent.EndTrain.Train.Position

local tweeningInfo = TweenInfo.new(
    40,
    Enum.EasingStyle.Linear,
    Enum.EasingDirection.InOut,
    0,
    false,
    0   
)

local ThroughCityTrain = {CFrame = CFrame.new(endTrain)}

local tweenTrain = TweenService:Create(Train,tweeningInfo,ThroughCityTrain)

1 answer

Log in to vote
0
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
6 years ago

CFrame.new(position) makes a CFrame located at position with the default orientation.

You can preserve the orientation of Train but move it to endTrain by constructing the final CFrame as follows:

Train.CFrame - Train.Position + endTrain
Ad

Answer this question