Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

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

This discussion is preserved as it was. New answers, comments, and votes are closed.