How do i separate boss attacks and wins

how do i make it so that when the player defeats the boss it will print “You win” but whenever i run the script after the function it would print “You win”.

coroutine.wrap(function()
		while wait(2) do
			if not canAttack then continue end

			HammerChallenge()


			-- example creation
			monster.ForceField.Visible = false
			local animObj = Instance.new("Animation")
			animObj.AnimationId = "rbxassetid://" .. 6309504704
			animation = monster.Humanoid:LoadAnimation(animObj)
			animation:Play() 

			animation.Stopped:Wait() -- wait for it to end
			local new = Instance.new("ForceField")
			new.Parent = monster
		end
	end)()
	
wait(1)

	print("You win")

Maybe check if the boss’s health is 0 then print.

EDIT: Here’s a code if you need,

if boss.Humanoid.Health==0 then
   print("You win")
end

-- or you can do

boss.Humanoid.Died:Connect(function())
   print("You win")
end)