Hello I wrote this script that will open a door but the door is not tweening, it just instantly opens, how can I make it slowly open and close?
local isopen = script.Parent.IsOpen
local idle = true
local button1 = script.Parent.Button1
local button2 = script.Parent.Button2
local click1 = button1.ClickDetector
local click2 = button2.ClickDetector
function active(silent)
if idle and not script.Parent.Locked.Value then
idle = false
local count = 0.07
if not isopen.Value then
if not silent then
script.Parent.Door1["Open" .. math.random(1,3)]:Play()
end
for i = 1, 1 do
wait()
script.Parent.Door1.CFrame = script.Parent.Door1.CFrame * CFrame.new(count * 54,0,0)
script.Parent.Door2.CFrame = script.Parent.Door2.CFrame * CFrame.new(count * 54,0,0)
if i < 18 then
count = count * 1.05
else
count = count / 1.05
end
end
isopen.Value = true
else
if not silent then
script.Parent.Door1["Close" .. math.random(1,3)]:Play()
end
for i=1, 1 do
wait()
script.Parent.Door1.CFrame = script.Parent.Door1.CFrame * CFrame.new(-count * 54,0,0)
script.Parent.Door2.CFrame = script.Parent.Door2.CFrame * CFrame.new(-count * 54,0,0)
if i < 18 then
count = count * 1.05
else
count = count / 1.05
end
end
isopen.Value = false
end
wait(0.5)
idle = true
end
end
button1.ClickDetector.MouseClick:connect(function()
button1.Push:Play()
active()
end)
button2.ClickDetector.MouseClick:connect(function()
button2.Push:Play()
active()
end)