making a text button open and close a GUI on click and it's not working. Here is the script
01 | local Button = script.Parent |
02 | local stat = game.StarterGui.Menu.Frame |
03 |
04 | Button.MouseButton 1 Click:Connect( function () |
05 | if stat.Visible = = false then |
06 | stat.Visible = true |
07 | else |
08 | stat.Visible = false |
09 | end |
10 | 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:
01 | local Button = script.Parent |
02 | local stat = script.Parent.Parent:WaitForChild( "Frame" ) |
03 |
04 | Button.MouseButton 1 Click:Connect( function () |
05 | if stat.Visible = = false then |
06 | stat.Visible = true |
07 | else |
08 | stat.Visible = false |
09 | end |
10 | 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:
1 | local Button = script.Parent |
2 | local stat = script.Parent.Parent:WaitForChild( "Frame" ) |
3 |
4 | Button.MouseButton 1 Click:Connect( function () |
5 | stat.Visible = not stat.Visible |
6 | 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.
1 | Button.MouseButton 1 Click:Connect( function () |
2 | stat.Visible = not stat.Visible |
3 | 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:
01 | local Button 1 = script.Parent.Button 1 |
02 | local Button 2 = script.Parent.Button 2 |
03 | local Frame = script.Parent.Frame |
04 |
05 | Button 1. MouseButton 1 Click:connect( function () |
06 | Frame.Visible = true |
07 | end ) |
08 |
09 | Button 2. MouseButton 1 Click:connect( function () |
10 | Frame.Visible = false |
11 | end ) |
Last but not least, make the different text on each button!