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

How To Make a Text Button Open a Frame?

Asked by 7 years ago

How can I make a text button open up a new frame?

2 answers

Log in to vote
1
Answered by 7 years ago

Remember, you have to first show your work, i tried telling you in the chat... just say this..

create screen gui then insert a frame called a and another frame called b insert a textbutton in frame a then create a script and type this:

local a = script.Parent.Parent.Parent.b
script.Parent.MouseButton1Click:connect(function()
    a.Visible = not a.Visible
end   -- i forgot, i think you should change it to  end), change it to end) if this doesn't work

Hope this Helps

(Ps: always work first and not ask for it or else you are violating the rule laws...)

0
Interesting, mine is a lot more complex. Never thought of this! Cowation 50 — 7y
0
greatniel80, you should change the end to end) because you have to complete the function. BunnyFilms1 297 — 7y
Ad
Log in to vote
0
Answered by 7 years ago

Hello. I slightly do not understand your question, but I will try to answer it anyway. To answer your question, create any sort of button in a ScreenGui in the StarterGui. I will use a TextButton for this answer. Then add a Frame parented into that same ScreenGui. Create a Script inside that ScreenGui and follow these steps. First we must define the variables for the TextButton and Frame.

local gui = script.Parent
local button = gui.TextButton
local frame = gui.Frame

TextButtons come with multiple events corresponding to when the player's mouse clicks the object. We will now create a function to tell what the server should do when the button is pressed.

local function onClick() -- Create the function
    if frame.Visible == true then -- If the frame is seen, disable the visibility, otherwise enable it.
        frame.Visible == false
    else
        frame.Visible == true
    end
end

Now that we have the function created, we will now add the click event and tie the function to it.

button.MouseButton1Click:connect(onClick) -- onClick is the function name. MouseButton1Click is the event.

Now run the game in studio and press the button. The frame can now be toggled via the TextButton. Use this example as a reference to your game. Feel free to use the code and edit it. I hope you find this helpful!

0
Where do i add the click event? ItzCarnage115555555 -3 — 7y
0
I would recommend at the very end of the script, MouseButton1Click is an event for the TextButton. You may place this any point in the script as long as it's after the function. Or else it will return an error. Cowation 50 — 7y

Answer this question