Problem with debounce or math

The script seems the same in all of the 3 parts but the third one doesn’t execute or even print the
“count 3”. It looks basically identical to the last 2 versions of it and I think the problem lies in my debounce or the

count = count + 1

The script:

local function punch()
	if db then return end
	if count == 1 then
		print("count 1")
		print(1)
		db = true
		Combat1:Play()
		count = count + 1
		wait(0.5)
		Combat1:Stop()
		db = false
		elseif count == 2 then
		print("count 2")
		if db == false then 
			db = true
			print(2)
			Combat2:Play()
			count = count + 1
			wait(0.5)
			Combat2:Stop()
			db = false
			elseif count == 3 then	
			print("count 3")
			if db == false then
				db = true
				print(3)
				Combat3:Play()			
				wait(0.5)
				Combat3:Stop()
				db = false
			end
		end
	end
end

The reason is that the elseif count == 3 then statement is directly a part of if db == false then instead of being a part of if count == 1 then statement.
You need to add an end after Combat2:Stop() db = false.

the term,

 if debounce

means, if debounce is true. If your debounce is set to true, then thats a problem.

  if not debounce

means that “if debounce is not true, hence false, …”

Also, I do think that you might have lost track of the amount of changes to the bool value, db. If so then track the latest value you placed on db. I remember I had that same problem with debounce before a long time ago, so that might be the solution to your problem.