Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Open/Close script opens, but doesn't close (?)

local logged = Instance.new("BoolValue")
logged.Parent = player
logged.Name = "loggedIn"
local gui = playerGui:WaitForChild("modPanel")
local Login = gui.Login
local Frame = playerGui.modPanel.Frame
local isOpen = playerGui.modPanel.Open
function onClick()
	if logged.Value == false then
		if Login.Visible == false then
			Login.Visible = true
		elseif Login.Visible == true then
		Login.Visible = false
		elseif isOpen.Value == true then
			Frame.Visible = false
			isOpen.Value = false
		elseif isOpen.Value == false then
			Frame.Visible = true
			isOpen = true
			end
		end
	end
script.Parent.MouseButton1Down:connect(onClick);

I have got this script, the button works and the login screen opens, you can login and everything is fine, the Frame opens but you cannot close it in any way, no errors are printed out and I have tried everything

1 answer

The way I see it your "else if" statements are getting in the way of your IF statements also you have not changed the value of the isOpen bool you just put this:

isOpen = true -- make this isOpen.Value = true

If that doesn't work Try this:

local logged = Instance.new("BoolValue")
logged.Parent = player
logged.Name = "loggedIn"

local gui = playerGui:WaitForChild("modPanel")
local Login = gui.Login
local Frame = playerGui.modPanel.Frame
local isOpen = playerGui.modPanel.Open

local function onClick()
      if logged.Value == false and not isOpen.Value == true then
            if Login.Visible == false then
                Login.Visible = true
            elseif Login.Value == true then
                Login.Visible = false
            end
      end

      if isOpen.Value == true and logged.Value == true then
            Frame.Visible = false
            isOpen.Value = false
      elseif isOpen.Value == false and logged.Value == true then
            Frame.Visible = true
            isOpen.Value = true
      end
end

script.Parent.MouseButton1Down:connect(onClickLOG)

This discussion is preserved as it was. New answers, comments, and votes are closed.