i need to open or close gui by pressing a key, but it only closes and opens without second pressing
local u = game:GetService("UserInputService")
u.InputBegan:Connect(function(input) -- input is when you press a key
if input.KeyCode == Enum.KeyCode.N then -- click N
script.Parent.Frame.Visible = false
else
script.Parent.Frame.Visible = true
end
end)
I need to make it so that when the key is pressed for the first time, Frame becomes invisible and when the button N is pressed for the second time, Frame becomes visible
local u = game:GetService("UserInputService")
local on = false
u.InputBegan:Connect(function(input) -- input is when you press a key
if input.KeyCode == Enum.KeyCode.N then -- click N
on = not on -- if its true, its false. if its false, its true.
script.Parent.Frame.Visible = on
end
end)
the reason ur script isnt working is because ur putting else on the keycode statement that detects if ur pressing n… so instead make a boolean variable that is set to false first (or true if u want it on first) and use not to disable and enable it automatically…