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

Why does my Close/Open Script for my GUI button not work at all?

Asked by 5 years ago

So I have a Close/Open, and I'm developing a GUI that when click closes the frame its in and opens another frame and the script won't work exactly went wrong. (I know I'm dumb)

---Information--- The button is in frame 1 and has a local script in it for the script.

---Script---

script.Parent.MouseButton1Click:Connect(function()
 if script.ScreenGui1.Frame1.Visible == true then
    script.ScreenGui1.Frame1.Visible = false
    wait(0)
 if script.ScreenGui1.Frame2.Visble == false then
    script.ScreenGui1.Frame2.Visible = true
end
end
end)
0
Can you provide a screenshot of how the objects are organised, please? Wiscript 622 — 5y
0
how? vincentthecat1 199 — 5y
0
Is the GUI a child of the script? RyanTheLion911 195 — 5y
0
no vincentthecat1 199 — 5y
View all comments (2 more)
0
Okay, let me try something. RyanTheLion911 195 — 5y
0
Scratch that, for this problem to be solved you would need to provide more information such as where the script is and the frame etc. RyanTheLion911 195 — 5y

2 answers

Log in to vote
0
Answered by
3wdo 198
5 years ago

i found a solution:

put the button in the gui and put this script in the button:

frame1 = script.Parent.Parent.Frame1
frame2 = script.Parent.Parent.Frame2

script.Parent.MouseButton1Click:Connect(function()
    frame1.Visible = not frame1.Visible
end)

script.Parent.MouseButton1Click:Connect(function()
    frame2.Visible = not frame2.Visible
end)
Ad
Log in to vote
0
Answered by 5 years ago

Alright, you forgot an elseif ;-;

local btn = script.Parent

btn.MouseButton1Click:connect(function()
    if script.ScreenGui1.Frame1.Visible == true then
        script,ScreenGui1.Frame1.Visible = false
    elseif script.ScreenGui1.Frame1.Visible == false then
        script.ScreenGui1.Frame1.Visible = true
end
end
end)

its easy to see the problem

Answer this question