So basically if i click the button it would show a GUI, but if i click again again on it, it should close the GUI.Ok it shows the GUI only once but if i click again it stays frozen.GUI won't do anything after that.
Here is the script:
local button = script.Parent local frame = script.Parent.Parent.Frame button.MouseButton1Click:Connect(function() if frame.Visible == true then frame.Visible = false end if frame.Visible == false then frame.Visible = true end end)
It is because when the luau interpreter is gonna read that script, it is gonna see that the frame.Visible is true, run the statement and turn it false. Then, it is gonna see that frame.Visible is false, and turn it to true. What you should do to avoid this problem is:
local button = script.Parent local frame = script.Parent.Parent.Frame button.MouseButton1Click:Connect(function() if frame.Visible == true then -- if this runs, it is gonna turn false and not go through the else, if it doesn't, it is not gonna turn false and go to the else, which is gonna turn it true. frame.Visible = false else frame.Visible = true end end)
Hope this helped!