Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-1

Why is my Sliding Door Script not Working Correctly?

Asked by
SirPaco 66
9 years ago

My Script was working completely fine before I switched OpeningButton and ClosingButton to OpeningButton1 and OpeningButton2 and ClosingButton1 and ClosingButton2.

opening = script.Parent.GateOpeningButton1 and GateOpeningButton2.ClickDetector.MouseClick
closing = script.Parent.GateClosingButton1 and GateClosingButton2.ClickDetector.MouseClick

a = script.Parent.GatePart1
b = script.Parent.GatePart2

opened = false
moving = false

function open()
if opened or moving then return end
script.Parent.GateOpeningButton1 and GateOpeningButton2. = BrickColor.Yellow()
script.Parent.GateClosingButton1 and GateClosingButton2.BrickColor = BrickColor.Yellow()
moving = true
for i=1, 100 do
wait()BrickColor
a.CFrame=a.CFrame-a.CFrame.lookVector*.2
b.CFrame=b.CFrame-b.CFrame.lookVector*.2
end
moving = false
script.Parent.GateOpeningButton1 and GateOpeningButton2.BrickColor = BrickColor.Green()
script.Parent.GateClosingButton1 and GateClosingButton2.BrickColor = BrickColor.Red()
opened = true
end

function close()
if not opened or moving then return end
script.Parent.GateOpeningButton1 and GateOpeningButton2.BrickColor = BrickColor.Yellow()
script.Parent.GateClosingButton1 and GateClosingButton2.BrickColor = BrickColor.Yellow()
moving = true
for i=1, 100 do
wait()
a.CFrame=a.CFrame+a.CFrame.lookVector*.2
b.CFrame=b.CFrame+b.CFrame.lookVector*.2
end
moving = false
script.Parent.GateOpeningButton1 and GateOpeningButton2.BrickColor = BrickColor.Green()
script.Parent.GateClosingButton1 and GateClosingButton2.BrickColor = BrickColor.Red()
opened = false
end

opening:connect(GateOpeningButton1 and GateOpeningButton2)
closing:connect(GateClosingButton1 and GateClosingButton2)

Answer this question