Easing a change in CFrame direction

I know how to change the direction of an object using CFrame but how exactly would I make the transition of direction a smooth process instead of it instantly changing to the other parts CFrame position.

Heres what I tried so far -

script.Parent.Connector.Front.CFrame = CFrame.new(script.Parent.Connector.Front.Position, script.Parent.Waypointl[GoToName].Position)

Take a look at CFrame:lerp(). Unfortunately I can’t link it on mobile but a simple google should pull it up.

1 Like

Of course this would work, but could I possibly get an example as the examples i’m finding are very limited in explanation for what I want to do

To be used in a LocalScript:

local RunService = game:GetService("RunService")
local Stepped = RunService.Stepped
local Time = 1 --In seconds

	local OriginCFrame = Part1.CFrame
	for i = 0, 1, Time/60 do
		Part1.CFrame = OriginCFrame:Lerp(CFrame.new(OriginCFrame.Position, Part2.Position), i)

This will make the Part1 rotate towards Part2 smoothly in Time which is 1 second.

Tweens, they’re simple and very customisable!
Here’s a runthrough:

local TweenService = game:GetService("TweenService") --Get the service for tweening
local Info = TweenInfo.new(2, Enum.EasingStyle.Linear) --The information datatype, we'll use 2 seconds timing and Linear for a smooth tween
local PropertyTable = {
    CFrame = CFrame.new(script.Parent.Connector.Front.Position, script.Parent.Waypointl[GoToName].Position)
    --The property to tween is the index, the value is what to tween it to!

local Tween = TweenService:Create(
    script.Parent.Connector.Front.CFrame, --The Instance to tween
    Info, --The TweenInfo for the tween
    propertyTable --The property table for the tween
Tween:Play() --Don't forget to Play!

You can read more about Tweens here:

Think of lerping as moving a CFrame along a line to get to the destination by a fraction. Many use this in loops to make a smooth tween effect although mathematically it’s just being moved to the next point by an increment each time. I couldn’t tell you the difference between vector and CFrame lerping but I assume it’s just the difference between a vector and a matrix.