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

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

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)

6 comments

0

Can you provide a screenshot of how the objects are organised, please?

0

how?

0

Is the GUI a child of the script?

0

no

0

Okay, let me try something.

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.

2 answers

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)

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

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