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

How to use :lerp() to rotate & change position of part simultaneously?

Asked by
Spooce 78
9 years ago

I'm trying to make a little animation with a lever. It will slowly be pulled down when clicked. I can't seem to get it to rotate and change its position at the same time though. I've tried threading.

Suggestions?

01local Lever = script.Parent
02local Enabled = false
03 
04StartCFrame = Lever.CFrame
05EndCFrame = CFrame.new(118.1, 107.671, 70.582)
06 
07function Position()
08    for i = 0, 1, 0.1 do
09        Lever.CFrame = StartCFrame:lerp(EndCFrame, i)
10        Enabled = false
11        wait(0.05)
12    end
13end
14 
15function Rotate()
View all 30 lines...

1 answer

Log in to vote
0
Answered by 9 years ago

Try making a different script that also detects when it happens.

Like putting in a different script.

01local Lever = script.Parent
02local Enabled = false
03function Rotate()
04    for i = 1, 150 do
05        Lever.CFrame = StartCFrame * CFrame.Angles(math.rad(i), math.rad(0), math.rad(0))
06        wait()
07    end
08end
09 
10Lever.ClickDetector.MouseClick:connect(function()
11    if not Enabled then
12        Enabled = true
13        Spawn(Rotate)
14        Enabled = false
15    end
16end)

Place that into a different script?

crosses fingers hope it works!

Happy Thanksgiving!

Ad

Answer this question