So I'm making a combat test, and I'm trying to make a sword with a few skills. The skills work, but the sword's hitstun mechanic doesn't itself.

The way hitstun is marked is when a player's WalkSpeed is 0, because nothing else would reduce their speed to 0. When a player is hit they enter hitstun.

The problem is, the message "Done" prints about 1 second after the animation's finished, which is a strict no-no and breaks the game because the players cannot take damage or even take hitstun from the 2nd and 3rd swings of the sword.

script.Parent.SwingEvent.OnServerEvent:Connect(function(plr, cuttime)
	debounce = true
	script.Parent.hbox.Touched:Connect(function(part)
		if damageTaken == false and debounce == true then
			damageTaken = true
			if (game.Players:GetPlayerFromCharacter(part.Parent)) then
				local eplr = game.Players:GetPlayerFromCharacter(part.Parent)
				if eplr:WaitForChild("Blocking").Value == true then
					part.Parent.Humanoid:TakeDamage((baseDamage * 0.20) + pierce)
					spawn(function()
						local fx = game.ReplicatedStorage.Particles.GeneralCombat.Sparks:Clone()
						fx.Parent = script.Parent.hbox
						fx.Enabled = true
						wait()
						fx.Enabled = false
						wait(2)
						fx:Destroy()
					end)
				else
					part.Parent.Humanoid:TakeDamage(baseDamage)
					part.Parent.Humanoid.WalkSpeed = 0
					local anim = part.Parent.Humanoid:LoadAnimation(part.Parent["Character Controls"].Stun)
					anim:Play()
					spawn(function()
						wait(cuttime)
						part.Parent.Parent.Humanoid.WalkSpeed = 16
					end)
				end
			elseif (game.Players:GetPlayerFromCharacter(part.Parent.Parent))  then
				local eplr = game.Players:GetPlayerFromCharacter(part.Parent.Parent)
				if eplr:WaitForChild("Blocking").Value == true then
					part.Parent.Parent.Humanoid:TakeDamage((baseDamage * 0.20) + pierce)
					spawn(function()
						local fx = game.ReplicatedStorage.Particles.GeneralCombat.Sparks:Clone()
						fx.Parent = script.Parent.hbox
						fx.Enabled = true
						wait()
						fx.Enabled = false
						wait(2)
						fx:Destroy()
					end)
				else
					part.Parent.Parent.Humanoid:TakeDamage(baseDamage)
					part.Parent.Parent.Humanoid.WalkSpeed = 0
					local anim = part.Parent.Parent.Humanoid:LoadAnimation(part.Parent.Parent["Character Controls"].Stun)
					anim:Play()
					spawn(function()
					wait(cuttime)
						part.Parent.Parent.Humanoid.WalkSpeed = 16
					end)
				end
			elseif (part.Parent.Humanoid) and part.Parent.Humanoid.Name == "Elite" then
				local npc = part.Parent
				--Finish After
			elseif (part.Parent.Humanoid) then
				local npc = part.Parent
				--Finish After
			end
		end
	end)
	wait(cuttime)
	print("Done")
	debounce = false
	damageTaken = false
end)