Ive made stairs which should go up and down, it goes up when i press the button. I want it to go down when i press the button again. Why isnt it working?
Stair1 = script.Parent.Parent.Stair1 --All the variables
Stair2 = script.Parent.Parent.Stair2
Stair3 = script.Parent.Parent.Stair3
Stair4 = script.Parent.Parent.Stair4
Stair5 = script.Parent.Parent.Stair5
Stair6 = script.Parent.Parent.Stair6
Stair7 = script.Parent.Parent.Stair7
Stair8 = script.Parent.Parent.Stair8
Support1 = script.Parent.Parent.Support1
Support2 = script.Parent.Parent.Support2
Support3 = script.Parent.Parent.Support3
Support4 = script.Parent.Parent.Support4
Support5 = script.Parent.Parent.Support5
Support6 = script.Parent.Parent.Support6
Support7 = script.Parent.Parent.Support7
Support8 = script.Parent.Parent.Support8
value = script.Parent.Value
var = 0
local debounce = false
function onClicked(playerWhoClicked) --Checks if button is clicked
if not debounce then
if value.Value == false then --Is the value == false?
debounce = true
for i=1,10 do --Does the first Stair
Stair1.CFrame = Stair1.CFrame + Vector3.new(0,0.1,0)
Support1.CFrame = Support1.CFrame + Vector3.new(0,0.1,0)
wait(0.1)
end
for i=1,20 do
Stair2.CFrame = Stair2.CFrame + Vector3.new(0,0.1,0)
Support2.CFrame = Support2.CFrame + Vector3.new(0,0.1,0)
wait(0.1)
end
for i=1,30 do
Stair3.CFrame = Stair3.CFrame + Vector3.new(0,0.1,0)
Support3.CFrame = Support3.CFrame + Vector3.new(0,0.1,0)
wait(0.1)
end
for i=1,40 do
Stair4.CFrame = Stair4.CFrame + Vector3.new(0,0.1,0)
Support4.CFrame = Support4.CFrame + Vector3.new(0,0.1,0)
wait(0.1)
end
for i=1,50 do
Stair5.CFrame = Stair5.CFrame + Vector3.new(0,0.1,0)
Support5.CFrame = Support5.CFrame + Vector3.new(0,0.1,0)
wait(0.1)
end
for i=1,60 do
Stair6.CFrame = Stair6.CFrame + Vector3.new(0,0.1,0)
Support6.CFrame = Support6.CFrame + Vector3.new(0,0.1,0)
wait(0.1)
end
for i=1,70 do
Stair7.CFrame = Stair7.CFrame + Vector3.new(0,0.1,0)
Support7.CFrame = Support7.CFrame + Vector3.new(0,0.1,0)
wait(0.1)
end
for i=1,80 do
Stair8.CFrame = Stair8.CFrame + Vector3.new(0,0.1,0)
Support8.CFrame = Support8.CFrame + Vector3.new(0,0.1,0)
wait(0.1)
end
value.Value = true
debounce = false
print("done")
end
else if value.Value == true then --Is the value == true?
debounce = true
print("1")
for i=1,10 do
Stair1.CFrame = Stair1.CFrame + Vector3.new(0,-0.1,0)
Support1.CFrame = Support1.CFrame + Vector3.new(0,-0.1,0)
wait(0.1)
end
for i=1,20 do
Stair2.CFrame = Stair2.CFrame + Vector3.new(0,-0.1,0)
Support2.CFrame = Support2.CFrame + Vector3.new(0,-0.1,0)
wait(0.1)
end
for i=1,30 do
Stair3.CFrame = Stair3.CFrame + Vector3.new(0,-0.1,0)
Support3.CFrame = Support3.CFrame + Vector3.new(0,-0.1,0)
wait(0.1)
end
for i=1,40 do
Stair4.CFrame = Stair4.CFrame + Vector3.new(0,-0.1,0)
Support4.CFrame = Support4.CFrame + Vector3.new(0,-0.1,0)
wait(0.1)
end
for i=1,50 do
Stair5.CFrame = Stair5.CFrame + Vector3.new(0,-0.1,0)
Support5.CFrame = Support5.CFrame + Vector3.new(0,-0.1,0)
wait(0.1)
end
for i=1,60 do
Stair6.CFrame = Stair6.CFrame + Vector3.new(0,-0.1,0)
Support6.CFrame = Support6.CFrame + Vector3.new(0,-0.1,0)
wait(0.1)
end
for i=1,70 do
Stair7.CFrame = Stair7.CFrame + Vector3.new(0,-0.1,0)
Support7.CFrame = Support7.CFrame + Vector3.new(0,-0.1,0)
wait(0.1)
end
for i=1,80 do
Stair8.CFrame = Stair8.CFrame + Vector3.new(0,-0.1,0)
Support8.CFrame = Support8.CFrame + Vector3.new(0,-0.1,0)
wait(0.1)
end
value.Value = false
debounce = false
end
end
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)
It prints "Done" also it changes the Value to true after.

1 comment
On line 71, remove the space between else and if. So, 'elseif'