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

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

Asked by 10 years ago

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

Log in to vote
1
Answered by 10 years ago

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)
0
Okay, so mine will work if I use diffrent function names? Operation_Meme 890 — 10y
0
Exactly. SnazzyPine25 5 — 10y
0
Thx Operation_Meme 890 — 10y
Ad
Log in to vote
0
Answered by
red106 0
10 years ago

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)
0
Uhm, okay, but does mine have erorrs? Operation_Meme 890 — 10y

Answer this question