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?
local Lever = script.Parent
local Enabled = false
StartCFrame = Lever.CFrame
EndCFrame = CFrame.new(118.1, 107.671, 70.582)
function Position()
for i = 0, 1, 0.1 do
Lever.CFrame = StartCFrame:lerp(EndCFrame, i)
Enabled = false
wait(0.05)
end
end
function Rotate()
for i = 1, 150 do
Lever.CFrame = StartCFrame * CFrame.Angles(math.rad(i), math.rad(0), math.rad(0))
wait()
end
end
Lever.ClickDetector.MouseClick:connect(function()
if not Enabled then
Enabled = true
Spawn(Position)
Spawn(Rotate)
Enabled = false
end
end)
