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

local Gate = script.Parent
local Click = Gate.ClickDetector

local function OpenGate()
    Gate.Transparency = 1
    Gate.CanCollide = false
end

Click.MouseClick:connect(OpenGate)

Closing Button Script

local Gate = script.Parent
local Click = Gate.ClickDetector

local function CloseGate()
    Gate.Transparency = 0
    Gate.CanCollide = true
end

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

local Gate = script.Parent.Parent
local Click = script.Parent.ClickDetector
local GateOpen = false

local function OpenGate()
    if GateOpen == false then
    GateOpen = true
    Gate.Transparency = 1
    Gate.CanCollide = false
    elseif GateOpen == true then
    GateOpen = false
    Gate.Transparency = 0
    Gate.CanCollide = true
    end
end

Click.MouseClick:connect(OpenGate)
0
All that is happening is that the button is becoming transparent. SirPaco 66 — 9y
Ad

Answer this question