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

How to open a frame by clicking on a textbutton?

Asked by 6 years ago

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.

0
What is your native language? SuperAndresZ_YT 202 — 6y

2 answers

Log in to vote
0
Answered by 6 years ago

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

0
You can just use “someFrame.Visible = not someFrame.Visible” instead of using conditional statements to check if the frame is visible or not. User#20279 0 — 6y
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. Legoman654 100 — 6y
Ad
Log in to vote
0
Answered by
joshxie 25
6 years ago
Edited 6 years ago

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 ! :)

0
you would have to put the path joshxie 25 — 6y
0
for frame, it would be script.Parent.Parent.Frame , and for the button, it would be script.Parent joshxie 25 — 6y

Answer this question