Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I use CFrame:lerp()?

Asked by 8 years ago

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

Log in to vote
2
Answered by 8 years ago

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

0
What do you need the 'd' variable? rexbit 707 — 8y
0
He used it in his koolkid8099 705 — 8y
0
Thanks. BTW d is delay between each "frame" of moving. Vlatkovski 320 — 8y
Ad

Answer this question