Problem
I have a script that when pressed it will create a part and put it in the workspace 0,0,-5 away from the player. When let go it will destroy that Part. All that works fine but the player can summon two parts and the same time. So when one button is already being held another button can also be held and work. I want to prevent this. I've tried Multiple Solution like give both UIS the same debounce var. Although this make it so that you have to wait until the other debounce is finished until the other button can work. Which i don't want. I want it so that when a player holds a button any other buttons cannot work. When he lets go the button the he was holding onto it will have a debounce. And all other button do not have the same debounce. Hopefully that makes sense.
Script:
--Variables--
local Player = game.Players.LocalPlayer
local char = Player.Character
local en = true
local den = true
--Services--
local UIS = game:GetService("UserInputService")
--
UIS.InputBegan:Connect(function(Input)
if Input.KeyCode == Enum.KeyCode.Q then --Get the Q button--
if not en then return end--Debounces--
if not den then return end--Debounces--
den = false
en = false
Part = Instance.new("Part")--Creates A part--
Part.Parent = workspace
Part.CFrame = char.Head.CFrame * CFrame.new(0,0,-5)
wait(3)
en = true
end
end)
--
UIS.InputEnded:Connect(function(Input)--When Let go it will destroy the Part--
if Input.KeyCode == Enum.KeyCode.Q then
Part:Destroy()
den = true
end
end)
--
UIS.InputBegan:Connect(function(Input)--Basically same thing but with a different Debounce--
if Input.KeyCode == Enum.KeyCode.E then
if not den then return end
if not en then return end
en = false
den = false
Part2 = Instance.new("Part")
Part2.Parent = workspace
Part2.CFrame = char.Head.CFrame * CFrame.new(0,0,-5)
wait(3)
den = true
end
end)
--
UIS.InputEnded:Connect(function(Input)--When let go it will destroy the part
if Input.KeyCode == Enum.KeyCode.E then
Part2:Destroy()
en = true
end
end)

2 comments
You just need a simple flag that is set when you spawn the part then only on InputEnded set the flag back to false. Use only one event listener as well. If the flag is true on inputbegan then return the function block.
I'm on my mobile and I'm working atm. If you need any more help when I get to my desktop I can help more.