when I try to bind a key bind to a screen GUI and use the key bind it enables the GUI I want the same key bind to be able to disable the GUI this is the method I tried but it doesn’t work
local GUI = script.Parent.Parent.Invetory
UIS.InputBegan:Connect(function(input) -- Enables GUI
if input.UserInputType == Enum.UserInputType.Keyboard then
if input.KeyCode == Enum.KeyCode.E and GUI.Enabled == false then
GUI.Enabled = true
print("Enabled")
return GUI
end
end
end)
UIS.InputBegan:Connect(function(input) -- Should disable GUI but it doesnt
if input.UserInputType == Enum.UserInputType.Keyboard then
if input.KeyCode == Enum.KeyCode.E then
if GUI.Enabled == true and input.KeyCode == Enum.KeyCode.E then
GUI.Enabled = false
print("Disabled")
return GUI
end
end
end
end)