When you click on the clickbox the door should open or close depending on the open value
https://gyazo.com/91eac152b5f7a398c9ed92b9d383d72e here is what is happening instead
I believe it has to do with me changing values too soon or something but that's my only theory and I don't see why that would be the case.
Output shows no errors so the code is technically working
https://gyazo.com/27eab086dff60e2cd9ee5d2423e69dfc - photo of the door model in explorer
debounce = false
open = false
model = script.Parent.Parent.Parent
Door = model.Frame
script.Parent.MouseClick:connect(function(part)
if debounce == true and open == true then return end
debounce = true
for x = 0, 15 do
wait(.05)
if open == false then
Door.CFrame = Door.CFrame + Vector3.new(0,0,-.30)
open = true
wait(3)
debounce = false
end
end
end)
script.Parent.MouseClick:connect(function(part)
if debounce == true and open == false then return end
debounce = true
for x = 0, 15 do
wait(.05)
if open == true then
Door.CFrame = Door.CFrame + Vector3.new(0,0,.30)
open = false
wait(3)
debounce = false
end
end
end)
Any help is appreciated

2 comments
Still applying everything I learned as I write this, but thank you so much! I never expected such a large, well written, and informative response! Thank you for everything!
Also I changed the 'and' to an 'or' in the if debounce == true and open == true line and it fixed the clicking more than once problem. The door is working!!! thank you! :)