Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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)

1 comment

0

I edited my answer, try it again..

1 answer

✓ Accepted answer

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)

1 comment

0

All that is happening is that the button is becoming transparent.

This discussion is preserved as it was. New answers, comments, and votes are closed.