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

Diffrence between TweenService and Lerp?

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

✓ Accepted answer

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!")

3 comments

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.

0

Thx! would you mind telling me how to pause a tween?

0

Just use Tween:Stop(), you can Tween:Play() when you want return the tween.

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