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

Diffrence between TweenService and Lerp?

Asked by 6 years ago

What is the difference between using Tween or Lerp to animate a brick's movement? Also can someone give me an example code of how to use Lerp? I know how to use TweenService but not Lerp. Thanks C:

1 answer

Log in to vote
0
Answered by
D3LTA_Y 72
6 years ago

Okay, here's an example of how to use Lerp:

local p = Instance.new("Part", workspace) -- Our part to lerp.
p.Anchored = true -- I just preferred
local CF1 = CFrame.new() -- We need a new CFrame method (empty) to make the Transition.(Simulation of "p"'s Cframe)
local CF2 = CFrame.new(10, 0, 0) -- Our goal.

function Lerping(part)
    for i = 0, 1, .01 do -- "i" will be our alpha number, it must between 0 and 1. 
   part.CFrame = CF1:lerp(CF2, i) -- "i" will be added every time the loop is executed again.   
    wait()
    end
end

Lerping(p)

print("Ola mundo da Lua!")
0
the difference is: the execution method, except that a Tween can be paused, not a lerp, you would need a specific code just to make your lerp stop completely and another to cause it to continue, anyway, varies much of the programmer's need. D3LTA_Y 72 — 6y
0
Thx! would you mind telling me how to pause a tween? Worthy0ne 68 — 6y
0
Just use Tween:Stop(), you can Tween:Play() when you want return the tween. D3LTA_Y 72 — 6y
Ad

Answer this question