My sword's hitbox won't close

  1. I am trying to make simple sword

2.My sword’s hitbox won’t close so sword doesnt working

  1. I replaced hitbox = false position also tried task.delay

sword.Activated:Connect(function(Hit)
	if db then return end
	if db == false then
		db = true
		if hax == 1 and db == true then
			vur()
			hitbox = true
			Hitbox.Touched:Connect(function(re)
				if hitbox == true then
					local plr = re.Parent:FindFirstChild("Humanoid")
					if plr then
					plr:TakeDamage(dmg) 
						hitbox = false end
					hitbox = false
					hax = 2
					wait(cd)
					db = false
				end
			end)
		end

		if hax == 2 and db == true then
			
			hitbox = true
			vur2()	
			Hitbox.Touched:Connect(function(re)
				if hitbox == true then
					local plr = re.Parent:FindFirstChild("Humanoid")
					if plr then
					plr:TakeDamage(dmg2) 
						hitbox = false end
					hitbox = false
					hax = 1
					wait(cd)
					db = false
				end

			end)
		end

	end
end)

Why do you have a hitbox for your sword? You can just weld it to the sword and it’ll be much easier.

I don t wanna do dmg while idle.

Okay, so only do damage when the animation for the sword swinging is playing? Maybe that would work?