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

How does lerp() work?

1 answer

✓ Accepted answer

lerp takes a parts current cframe and generates a path with a number (alpha between 0 and 1) depicting the starting cframe and the end cframe (with other cframes inbetween 0 and 1). You would start this out with a simple Part

local part = Instance.new('Part', workspace)

You would then create a for statement to create a smooth CFraming

for i = 0, 1, 0.0001 do
-- Lerp here
wait(0.01) -- small numbers for Smooth CFraming
end

Next you would call the lerp method inside the for loop lerp can only be called as a method on CFrames

part.CFrame = part.CFrame:lerp(part.CFrame+Vector3.new(21,04,30),i)

Together it would look like

local part = Instance.new('Part', workspace)
for i = 0, 1, 0.0001 do
part.CFrame = part.CFrame:lerp(part.CFrame+Vector3.new(21,04,30),i)
wait(0.01)
end

Thats it really. have a nice time with your new knowledge!

2 comments

0

I just want to clarify that the first argument is the goal CFrame

0

Yes

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