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

How to open a frame by clicking on a textbutton?

How to open a frame by clicking on a textbutton? I need this plis , I can not understand much because I do not speak English, This will help me.

1 comment

0

What is your native language?

2 answers

You should look into the events for textbuttons and the properties for frames. Textbuttons have an easy event that does what you are needing:

http://wiki.roblox.com/index.php?title=API:Class/GuiButton/MouseButton1Click

here's a basic function to get you started. It will trigger an event when the user clicks the button making the designated frame not visible.

someTextButton.MouseButton1Click:connect(function()
	someFrame.Visible = false
end)

You can use IF statements to appropriately set the frame's visibility after determining if it is visible or not

2 comments

0

You can just use “someFrame.Visible = not someFrame.Visible” instead of using conditional statements to check if the frame is visible or not.

0

Correct, but I'm assuming OP is less familiar with the conditional statement. Would be better for him to gain the experience of working through IF statements.

This script will toggle it on / off depending on its current visibility, very straight - forward :) replace the paths to the frame and the button

--< Variables >--
local guiToClose = someFrame
local button = someButton

--< Functions >--
function toggleVisibility()

	guiToClose.Visible = not guiToClose.Visible

end

--< Connections >--
button.MouseButton1Clicked:connect(toggleVisibility)

enjoy, please comment any issues ! :)

3 comments

0
0

you would have to put the path

0

for frame, it would be script.Parent.Parent.Frame , and for the button, it would be script.Parent

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