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

How do I use CFrame:lerp()?

Let's say I have a partPart1. The CFrame I want to move it to is the CFrame of another part, Part2. I want to use CFrame:lerp() to move it with tweening its CFrame, with a delay of d. How do I do this?

1 answer

✓ Accepted answer

Ok, at first glimpse Lerp() may seem complicated, but its rather simple. Solerp stands for Linear Interpolation. Lerping is a mathematical technique for producing intermediate states between a start and an endpoint. This is very similar to how you tween guis. To use lerp, you need to loop may a loop so it can smoothly glide to another Cframe.

--------------Variables----------------
Part1 = game.Workspace.part1
Part2 = game.Workspace.part2
d = nil

------------Code------------------------
for i = 0,1, .1 do
	d = i
	Part1.CFrame = Part1.CFrame:lerp(Part2.CFrame(d)
wait()
end

This will make the part lerp from its current position to another

~~Hope I Helped

3 comments

0

What do you need the 'd' variable?

0

He used it in his

0

Thanks. BTW d is delay between each "frame" of moving.

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