Im trying to animate a plane door but it isn’t working. I tried watching two youtube tutorials but it didn’t work. Can you guys try to fix my script?
open = false
local motor = script.Parent.Parent.Door2.Motor
script.Parent:WaitForChild('ClickDetector').MouseClick:connect(function()
if open == false then
script.Parent.ClickDetector.MaxActivationDistance = 0
for i = 1,5 do
motor.C1 = motor.C1 * CFrame.new(0,0,0.09)
wait(0.001)
end
for i = 1, 35 do
motor.C1 = motor.C1 * CFrame.new(0.09, 0 , 0)
wait(0.001)
end
open = true
script.Parent.ClickDetector.MaxActivationDistance = 10
elseif open == true then
script.Parent.ClickDetector.MaxActivationDistance = 0
for i = 1,35 do
motor.C1 = motor.C1 * CFrame.new(-0.09, 0, 0)
wait(0.001)
end
for i = 1, 5 do
motor.C1 = motor.C1 * CFrame.new(0,0,-0.09)
end
open = false
script.Parent.ClickDetector.MaxActivationDistance = 10
end
end)
Edit it for me if you see any mistakes