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

TweenService Part Rotation ( Advance help needed! ) ?

After learning about TweenService I made this script that makes model travel between parts smoothly using TweenService. (Script is shortened btw)

I can't find anywhere how to make the part rotate using TweenService tho, now the part will move to given destination, but that's it.

If you still don't understand what I want, imagine this - part moves from A to B ( I have that already ) makes a 90* turn and travels to next point.

tl;dr change the rotation of the part with TweenService using Orientation of the part or something else.

( Script inside a model )

local TweenService = game:GetService("TweenService")

local Model = script.Parent 
local PartRoot = script.Parent.Root

local Position1 = script.Parent.Pos1


local TargetPosition = Position1.CFrame
local PartSlideInfo = TweenInfo.new(
	4, 
	Enum.EasingStyle.Quint, 
	Enum.EasingDirection.InOut, 
	0, 
	false, 
	0 
)

local PartSlideTween = TweenService:Create(PartRoot, PartSlideInfo, {CFrame =
Position1.CFrame})



PartSlideTween:Play()


1 answer

✓ Accepted answer
local TweenService = game:GetService("TweenService")

local Model = script.Parent 

local PartRoot = Model:WaitForChild("Root")
local Position1 = Model:WaitForChild("Pos1")
local TargetCFrame = Position1.CFrame
local TargetOrientation = (RootPart.Orientation + Vector3.new(90,0,0))

local PartSlideInfo = TweenInfo.new(
    4, 
    Enum.EasingStyle.Quint, 
    Enum.EasingDirection.InOut, 
    0, 
    false,
    0 
)

local PartRotateInfo = PartSlideInfo --// Copies userdata

local TweenGoal1 = {CFrame = TargetCFrame}
local TweenGoal2 = {Orientation = TargetOrientation}

local PartSlideTween = TweenService:Create(
	PartRoot, PartSlideInfo, TargetGoal1
)

local PartRotateTween = TweenService:Create(
	PartRoot, PartRotateInfo, TweenGoal2
)

PartSlideTween:Play()
PartSlideTween.Completed:Wait()
PartRotateTween:Play()

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