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

How i click the TextButton to close and open?

Add a ScreenGui inside the StarterGui and add a TextButton or ImageButton. Add a LocalScript and script this:

script.Parent.MouseButton1Click:connect(function()
      script.Parent.Parent.Frame.Visible = not script.Parent.Parent.Frame.Visible
end)

4 comments

0

I do not know what it is you're asking. Close and Open what???

0

Should be using Connect. Also stop copying me.

0

you dont have to, connect and Connect do the exact same thing. Plus connect will never be deprecated.

0

Instead of Visible = not, do: Visible = false

2 answers

There have code.

script.Parent.MouseButton1Click:connect(function() -- Fire when they click.
	if script.Parent.Parent.Frame.Visible == true then -- Check if its visible.
		script.Parent.Parent.Frame.Visible = false
	else
		script.Parent.Parent.Frame.Visible = true
	end
end)

Next time try to be more clear with your questions.

Hello! I hope this code helps. We want to consolidate this code into one script to make it look neater, otherwise it's pretty simple (pm if you want that code).

local button = script.Parent; -- change to your button (if it's not the parent)
local frame = script.Parent.Frame; -- change to the frame you want to open/close

button.MouseButton1Down:connect(function() -- fire the code when button is clicked
	if frame.Visible == true then 
		frame.Visible == false
		-- logic here
	else
		frame.Visible == true
		-- logic here
	end
end)

Hope this helps!

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