Debounce Affecting Menu Script

I’m trying to make a GUI that slides in with TweenService when a player hits “M”. Before I threw in the extra debounce stuff, it all worked fine, except the button spamming. The scripts brings up the menu, blurs the background, and disables character movement. If a player button mashes “M”, it causes the menu, blur, and movement to go out of sync. I added the debounce scripts from the DevHub, but now, you can open the menu, but you can’t close it. Sometimes, you CAN close it, but then you can’t reopen it. Could someone tell me what’s wrong and why it’s doing that?

local menu = script.Parent
local menuScreen = menu.Menu
local blur = game.Lighting:WaitForChild("MainMenuBlur")
local player = game.Players.LocalPlayer
local playergui = player:WaitForChild("PlayerGui")

local playerMod = require(game:GetService("Players").LocalPlayer.PlayerScripts:WaitForChild("PlayerModule"))
local controls = playerMod:GetControls()

local RESET_SECONDS = 2
local isTouched = false 

local hotkey = Enum.KeyCode.M
local UIS = game:GetService("UserInputService")
local open = false

menuScreen.AnchorPoint = Vector2.new(0, 0)
menuScreen.Position = UDim2.new(0.272, 0, -0.55, 0)

UIS.InputBegan:Connect(function(key, gp)
	if key.KeyCode == hotkey then
		if UIS:GetFocusedTextBox()== nil then
			if open == false then
				if not isTouched then 
					isTouched = true  
				open = true 
				controls:Disable()
				blur.Enabled = open
					menu.Menu:TweenPosition(UDim2.new(0.272, 0, 0.27, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Quint)
					wait(RESET_SECONDS) 
					isTouched = false 
				elseif open == true then
				open = false
				controls:Enable()
				blur.Enabled = open
						menu.Menu:TweenPosition(UDim2.new(0.272, 0, -0.55, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Quint)
				end
			end
		end
	end
end)

(DeBounce stuff is from the DevHub)