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?
01 | local Lever = script.Parent |
02 | local Enabled = false |
03 |
04 | StartCFrame = Lever.CFrame |
05 | EndCFrame = CFrame.new( 118.1 , 107.671 , 70.582 ) |
06 |
07 | function 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 |
13 | end |
14 |
15 | function Rotate() |
Try making a different script that also detects when it happens.
Like putting in a different script.
01 | local Lever = script.Parent |
02 | local Enabled = false |
03 | function 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 |
08 | end |
09 |
10 | Lever.ClickDetector.MouseClick:connect( function () |
11 | if not Enabled then |
12 | Enabled = true |
13 | Spawn(Rotate) |
14 | Enabled = false |
15 | end |
16 | end ) |
Place that into a different script?
crosses fingers hope it works!
Happy Thanksgiving!