Blocking System Broken

I am trying to make a blocking system, It works fine if you hold F for a while and let go.
But if you press F, It breaks and the blocking system won’t work.
The blocking system is a number value that start at the value 1 and counts down every 0.1 seconds, But if you press F instead of holding F it stays at the value stays at the number 1.

uis.InputBegan:Connect(function(input, gameProccesedEvent)
	if gameProccesedEvent then return end
	if char:FindFirstChild("Block") then return end
	if db then return end
	db = true
	
	if input.KeyCode == Enum.KeyCode.F then
		
		value = true
		
		BlockingTrack:Play()
		
		local Block = Instance.new("NumberValue")
		Block.Parent = char
		Block.Name = "Block"

		Block.Value = 1
		
	end
	
	task.wait(1.5)
	db = false
end)

uis.InputEnded:Connect(function(input, gameProccesedEvent)
	if gameProccesedEvent then return end
	if db then return end
	db = true

	if input.KeyCode == Enum.KeyCode.F then
		
		value = false
		
		if char:FindFirstChild("Block") then
			
			local Block = char:FindFirstChild("Block")
			
			Block:Destroy()
			
			print(value)
			
		end
		
		BlockingTrack:Stop()
		
	end
	
	db = false
end)

while task.wait(0.1) do

	if char:FindFirstChild("Block") then

		local Block = char:FindFirstChild("Block")

		if Block.Value > 0 then

			Block.Value -= 0.1

			print(value)

		elseif Block.Value <= 0 or value == false then

			value = false

			BlockingTrack:Stop()

			Block:Destroy()

			print(value)

			break

		elseif not char:FindFirstChild("Block") or value == false then

			BlockingTrack:Stop()

			print(value)

		end


	end

end
1 Like

if you put this near the top does it help?
if input.KeyCode != Enum.KeyCode.F then return end

Sorry for the late reply, But no it doesn’t help.
I am working on making it events seeing of it works.

1 Like