So I have script that uses CFrame to basically 'slide' the door open. I've used my old template which opened the door, waited a second or two then closed by itself. This script however, I remade from scratch in hopes of making it so that once its open it stays open and must be clicked again in order to be closed. This is the script. Interestingly enough, no errors pop up but the door fails to open whenever I click it.
bin = script.Parent
check1 = script.Parent.Open --A boolvalue used to confirm if the door is open or not.
check2 = script.Parent.Close -- Another boolvalue used to confirm if the door is closed or not
debounce = true
check1 = false
check2 = true
function open()
if debounce == true then
debounce = false
end
if check1 == false then
check1 = true
end
if check2 == true then
check2 = false
end
for i = 1,90 do
bin.CFrame = CFrame.new(bin.CFrame.x,bin.CFrame.y,bin.CFrame.z - .1)
wait()
end
debounce = true
end
function close()
if debounce == true then
debounce = false
end
if check1 == true then
check1 = false
end
if check2 == false then
check2 = true
end
for i = 1,90 do
bin.CFrame = CFrame.new(bin.CFrame.x,bin.CFrame.y,bin.CFrame.z + .1)
wait()
end
debounce = true
end
bin.ClickDetector.MouseClick:connect(open)
bin.ClickDetector.MouseClick:connect(close)

1 comment
I did this earlier it turns out an 'elseif' statement is needed instead of the 'else' at line 8. Other than that thanks!