Help with tool combo

Ok, so I’m trying to make a tool combo system but I can’t figure out how to reset the combo when the tool hasn’t been activated in 0.5 seconds.

local attackAnimationCombo = 0
local currentTime = tick()

local AttackCooldown = 0.5
local LastAttackCooldown = 1
local lastTime = 0

local function playAnimation()
	attackAnimationCombo = (attackAnimationCombo + 1) % 2
end

local function onToolActivated()
	currentTime = tick()
	if currentTime - lastTime < AttackCooldown then
		lastTime = currentTime
		playAnimation()
		
	elseif currentTime - lastTime >= LastAttackCooldown then
		lastTime = currentTime
		attackAnimationCombo = 0
		playAnimation()
	end
end