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

How do I make a script that opens/closes a gui?

Having trouble with this! This script might have a lot of errors:

Opening button:

function onClicked()
local open = script.Parent.Parent
local close = script.Parent.Parent
open.Visible = true
if script.Parent.Parent.Visible == true then
print = ("Opened")
end
end

script.Parent.MouseButton1Click:connect(onClicked)

Closing Button:

function onClicked()
local open = script.Parent.Parent
local close = script.Parent.Parent
close.Visible = false
if script.Parent.Parent.Visible == false then
print =  ("Closed")
end
end

script.Parent.MouseButton1Click:connect(onClicked)

2 answers

✓ Accepted answer

To start off please fully detail the assets of your GUI

For what i see you're doubling the variable. You're also using it without sense. If a function is the make something true then whatever comes when it is true should be included in the function. Finally, if both functions have one name then the script would break. So use it in separate names. Use it like this:

local open = script.Parent.Parent

function Open()
open.Visible = true
print = ("Opened")
end

function Close()
open.Visible = false
print = ("Closed")
end

function Connect()
if open.Visible == true then
Open()
else
Close()
end
end

script.Parent.MouseDown1Down:connect(Connect)

3 comments

0

Okay, so mine will work if I use diffrent function names?

0

Exactly.

0

Thx

Open Script

local Button = script.Parent
Frame = script.Parent.Parent.Front --This is a example


function onClick()
	
	Frame.Visible = true -- make sure it says true if  you want it to open

end


Button.MouseButton1Click:connect(onClick)

Close Script

local Button = script.Parent
Frame = script.Parent.Parent.Menu -- this is just a example



function onClick()


Frame.Visible = false --leave it false if you want it to close


end

Button.MouseButton1Down:connect(onClick)

1 comment

0

Uhm, okay, but does mine have erorrs?

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