The Scripts are supposed to function for the Gate but they are just functioning for the buttons with the Scripts and ClickDetectors in them.
Opening Button Script
1 | local Gate = script.Parent |
2 | local Click = Gate.ClickDetector |
3 |
4 | local function OpenGate() |
5 | Gate.Transparency = 1 |
6 | Gate.CanCollide = false |
7 | end |
8 |
9 | Click.MouseClick:connect(OpenGate) |
Closing Button Script
1 | local Gate = script.Parent |
2 | local Click = Gate.ClickDetector |
3 |
4 | local function CloseGate() |
5 | Gate.Transparency = 0 |
6 | Gate.CanCollide = true |
7 | end |
8 |
9 | Click.MouseClick:connect(CloseGate) |
Because you had 2 scripts if you clicked, then both scripts would open and close it, so that means it would stay closed because it was closed right after it was opened. Puting it into one script will work...
01 | local Gate = script.Parent.Parent |
02 | local Click = script.Parent.ClickDetector |
03 | local GateOpen = false |
04 |
05 | local function OpenGate() |
06 | if GateOpen = = false then |
07 | GateOpen = true |
08 | Gate.Transparency = 1 |
09 | Gate.CanCollide = false |
10 | elseif GateOpen = = true then |
11 | GateOpen = false |
12 | Gate.Transparency = 0 |
13 | Gate.CanCollide = true |
14 | end |
15 | end |
16 |
17 | Click.MouseClick:connect(OpenGate) |