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

Why is my Fortress Gate with an Open and Close Button not Functioning?

Asked by
SirPaco 66
9 years ago

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

1local Gate = script.Parent
2local Click = Gate.ClickDetector
3 
4local function OpenGate()
5    Gate.Transparency = 1
6    Gate.CanCollide = false
7end
8 
9Click.MouseClick:connect(OpenGate)

Closing Button Script

1local Gate = script.Parent
2local Click = Gate.ClickDetector
3 
4local function CloseGate()
5    Gate.Transparency = 0
6    Gate.CanCollide = true
7end
8 
9Click.MouseClick:connect(CloseGate)
0
I edited my answer, try it again.. lucas4114 607 — 9y

1 answer

Log in to vote
1
Answered by
lucas4114 607 Moderation Voter
9 years ago

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...

01local Gate = script.Parent.Parent
02local Click = script.Parent.ClickDetector
03local GateOpen = false
04 
05local 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
15end
16 
17Click.MouseClick:connect(OpenGate)
0
All that is happening is that the button is becoming transparent. SirPaco 66 — 9y
Ad

Answer this question