What I'm trying to do is as following. When you click a button, it sets a state to false, and then when a loop has finished, it sets that state to true.
part = script.Parent
startCFrame = part.CFrame
openCFrame = CFrame.new(part.Parent.Open.Position)
closeCFrame = CFrame.new(part.Parent.Close.Position)
open = false
finished = true
part.ClickDetector.MouseClick:connect(function()
if open == false and finished == true then
finished = false --set it to false
for i = 0, 1, 0.01 do
part.CFrame = startCFrame:lerp(openCFrame,i);
wait();
open = true --When finished set it to true
finished = true --When finished set it to true
end
elseif open == true and finished == true then
finished = false --Set it to false
for i = 0, 1, 0.01 do
part.CFrame = startCFrame:lerp(closeCFrame,i);
wait();
open = false --When finished set it to true
finished = true --When finished set it to true
end
end
end)
For those that don't understand
My question is quite simple.
How. Do. I. *Do. That.

3 comments
And... your question is?
I kinda stated my question... "What I'm trying to do is as following. When you click a button, it sets a state to false, and then when a loop has finished, it sets that state to true."
and what is it doing instead? (The "instead" part should be your question title)