Im basically trying to make a castle gate open and close, but instead of having it as one large union(which would go through the wall up top) i've divided it into subsections, which will all give the illusion of one large gate when opening/closing. I am trying to have to move as for example an escalator, where one goes down and the other follows.(until it's at it's direct location ofc) I clicked my button and well nothing happened, not sure what caused this since I got see no errors.
Le Script
local Gate = true
local Delay = false
Gate1 = script.Parent.Parent.Gate1
Gate2 = script.Parent.Parent.Gate2
Gate3 = script.Parent.Parent.Gate3
Gate4 = script.Parent.Parent.Gate4
Gate5 = script.Parent.Parent.Gate
local Sound = script.Parent.Sound
function GateMoveUp2()
for I=1,5 do
Gate2.Position=Gate2.Position+Vector3.new(0,0.1,0)
wait(.1)
end
end
function GateMoveUp3()
for I=1,10 do
Gate3.Position=Gate3.Position+Vector3.new(0,0.1,0)
wait(.1)
end
end
function GateMoveUp4()
for I=1,15 do
Gate4.Position=Gate4.Position+Vector3.new(0,0.1,0)
wait(.1)
end
end
function GateMoveUp5()
for I=1,20 do
Gate5.Position=Gate5.Position+Vector3.new(0,0.1,0)
wait(.1)
end
end
function GateMoveDown2()
for I=1,5 do
Gate2.Position=Gate2.Position+Vector3.new(0,-0.1,0)
wait(.1)
end
end
function GateMoveDown3()
for I=1,10 do
Gate3.Position=Gate3.Position+Vector3.new(0,-0.1,0)
wait(.1)
end
end
function GateMoveDown4()
for I=1,15 do
Gate4.Position=Gate4.Position+Vector3.new(0,-0.1,0)
wait(.1)
end
end
function GateMoveDown5()
for I=1,20 do
Gate5.Position=Gate5.Position+Vector3.new(0,-0.1,0)
wait(.1)
end
end
script.Parent.ClickDetector.MouseClick:Connect(function()
if Delay == false then
Delay = true
if Gate == true then
GateMoveUp2()
GateMoveUp3()
GateMoveUp4()
GateMoveUp5()
Sound:Play()
Sound.Ended:Wait()
Gate=false
elseif Gate == false then
GateMoveDown2()
GateMoveDown3()
GateMoveDown4()
GateMoveDown5()
Sound:Play()
Sound.Ended:Wait()
Gate=true
end
Delay = false
end
end)
