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

Stopping lerp Midway?

Asked by
smd34 30
9 years ago

I made a lerp script and I was trying to make the bricks move to a certain but tween smoothly back to the original Position when mouse button up. How would I make it tween smoothly back to the original position without the brick having a spasm?

local FB2 = cam.RandoStuff.brick1.Weld
    local start = cf(.1, -.9, 0)
local endit =cf(-1,-2,0)

local moving = false

Mouse.Button2Up:connect(function()
    moving = false
    for i = 0, 1, .088 do
       wait(0.0009)
    FB2.C0 = endit:lerp(start, i) *cfang(RAD(90), 0, 0)

    end
end)


    Mouse.Button2Down:connect(function()
        moving = true
for i = 0, 1, .088 do
       wait(0.0009)
    FB2.C0 = start:lerp(endit, i) *cfang(RAD(90), 0, 0)
end
    end)

if moving==false then 
    ---- I think this is the problem. I want it to tween smoothly back into the original position
    -- as soon as  Mouse Button 2 goes up
    i = 0, 1, .088 
    FB2.C0 = endit:lerp(start, i) *cfang(RAD(90), 0, 0)
end

Answer this question