making a text button open and close a GUI on click and it's not working. Here is the script
local Button = script.Parent local stat = game.StarterGui.Menu.Frame Button.MouseButton1Click:Connect(function() if stat.Visible == false then stat.Visible = true else stat.Visible = false end end)
the answer above ain't gonna work cause the problem is in your "stat" variable, instead of using game.StarterGui... and so on try going like script.Parent.Parent... so here's an example:
local Button = script.Parent local stat = script.Parent.Parent:WaitForChild("Frame") Button.MouseButton1Click:Connect(function() if stat.Visible == false then stat.Visible = true else stat.Visible = false end end)
make sure to correct the frame position if it's incorrect.
Now there's nothing wrong with this script but if you want you can get shorter script by using what person above suggested, in this case it'll look similar to this:
local Button = script.Parent local stat = script.Parent.Parent:WaitForChild("Frame") Button.MouseButton1Click:Connect(function() stat.Visible = not stat.Visible end)
Good luck, hope this helped.
I see you did a different way, I do not know how to fix it, but I know a different way to do it, someone told me this before.
Button.MouseButton1Click:Connect(function() stat.Visible = not stat.Visible end)
Hope it helps. :3
Nope, not quite, but you can do this: Add 2 TextButtons or ImageButtons (your choice whether you want it as image or text). Make them in the same position as the other (and size). Name the first one "Button1". Name the Second one "Button2". Insert your frame/scrollingframe/textlabel/whatever. Put this all into a ScreenGui. (insert the ScreenGui into StarterGui (unless another reason)) Then insert a LocalScript into the ScreenGui and do the following:
local Button1 = script.Parent.Button1 local Button2 = script.Parent.Button2 local Frame = script.Parent.Frame Button1.MouseButton1Click:connect(function() Frame.Visible = true end) Button2.MouseButton1Click:connect(function() Frame.Visible = false end)
Last but not least, make the different text on each button!