So I have the following LocalScript that simply makes a ScreenGUI object appear and disappear when the button it’s in is pressed.
The object appears as it’s supposed to on the first press, but will not disappear upon subsequent activations.
local b = script.Parent
b.Activated:Connect(function()
if script.Parent.Parent.Settings.Enabled then
script.Parent.Parent.Settings.Enabled = 0
else
script.Parent.Parent.Settings.Enabled = 1
end
end)
Enabled proprety is a boolean (which means use either true or false),
and another way of disabling UI is by changing the visible proprety of any UI object (boolean)
local Button = script.Parent
local ToOpenGui = Button.Parent.Settings
Button.Activated:Connect(function()
if ToOpenGui.Enabled == false then
ToOpenGui.Enabled = true
elseif ToOpenGui.Enabled == true then
ToOpenGui.Enabled = false
end
end)
Instead of GUI objects inside GUI objects, use Frames. (Frames have .Visible property)