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

How i click the TextButton to close and open?

Asked by 5 years ago

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)
0
I do not know what it is you're asking. Close and Open what??? Launderer 343 — 5y
0
Should be using Connect. Also stop copying me. User#19524 175 — 5y
0
you dont have to, connect and Connect do the exact same thing. Plus connect will never be deprecated. outlook1234567890 115 — 5y
0
Instead of Visible = not, do: Visible = false CalvitoDeBrazzer -5 — 5y

2 answers

Log in to vote
0
Answered by 5 years ago

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.

Ad
Log in to vote
0
Answered by 5 years ago

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!

Answer this question