So I have an open and close script for one button, but it seems to not work what did I do wrong, and don't say why don't you put a close button on the Frame? Its because the frame does not have enough room.
1 | script.Parent.MouseButton 1 Click:Connect( function () |
2 | game.Players.LocalPlayer.PlayerGui.Catalog.Morphs.Visible = = true then |
3 | game.Players.LocalPlayer.PlayerGUI.Catalog.Morphs.Visible = false |
4 | elseif game.Player.LocalPlayer.PlayerGUI.Catalog.Morphs.Visible = = false then |
5 | game.Player.LocalPlayer.PlayerGUI.Catalog.Morphs.Visible = true |
6 | end |
7 | end ) |
well, you could write the code in fewer lines. liek this:
1 | local morphs = game.Players.LocalPlayer.PlayerGui.Catalog.Morphs |
2 | script.Parent.MouseButton 1 Click:Connect( function () |
3 | morphs.Visible = not Visible |
4 | end ) |
btw, there must be some other parts in ur code thats making it not work..
one of which could be that an error is taking place, because u forgot the if
keyword
or game.Players.LocalPlayer.PlayerGui.Catalog.Morphs is not a true directory, and etc
Well you did one simple mistake. Here's the corrected form:
1 | script.Parent.MouseButton 1 Click:Connect( function () |
2 | if game.Players.LocalPlayer.PlayerGui.Catalog.Morphs.Visible = = true then |
3 | game.Players.LocalPlayer.PlayerGUI.Catalog.Morphs.Visible = false |
4 | elseif game.Player.LocalPlayer.PlayerGUI.Catalog.Morphs.Visible = = false then |
5 | game.Player.LocalPlayer.PlayerGUI.Catalog.Morphs.Visible = true |
6 | end |
7 | end ) |
Basically you just missed putting an "if" before the first statement. Here's a shortened version of your code if you'd like to use that:
1 | local Catalog = game.Players.LocalPlayer.PlayerGui.Catalog |
2 |
3 | script.Parent.MouseButton 1 Click:Connect( function () |
4 | if Catalog.Morphs.Visible = = true then |
5 | Catalog.Morphs.Visible = false |
6 | elseif MorphCLog.Visible = = false then |
7 | Catalog.Morphs.Visible = true |
8 | end |
9 | end ) |
In the shortened version, a variable was added for your morph catalog and when you use it, you can use the variable instead of the long version.
Hope this fixed your problem. :)
Edit: Sorry if it might not be indented perfectly. Just re-indent (recommended) them correctly or un-indent them.