Help with a sword combo script

Hello guyzz

I have been working on a sword combo script recently and it is not working as I expected
please help me.The problem is the second attack (combo 2) is not playing even I click the mouse within a minute, the first attack (combo 1) is playing instead .

Another problem is the second attack (combo 2) sometimes play multiple times ( It should reset the combo to 1 after playing the second) .

Also please tell me if there is a better way to do this

thank you

Here is the script👇

 tool.Activated:Connect(function()
    	activated = true
    	local timediff = tick() - lastclick
    	if timediff > 1 and not candamage then
    		candamage = true
    		print(1)
    		local anime1 = Humanoid:LoadAnimation(swinganime1)
    		anime1:Play()
    		lastclick = tick()
    		combo = combo + 1
    	elseif combo == 1 and timediff < 1 then
    		print(2)
    		local anime2 = Humanoid:LoadAnimation(swinganime2)
    		wait(anime2.Length)
    		anime2:Play()
    		lastclick = tick()
    		combo = combo + 1
    		wait(1)
    		combo = 0
    		candamage = false
    	end
    		wait(1)
    		combo = 0
    		candamage = false
    end)