How to stop "AI MoveTo" function when player is dead

I have a custom event that chases a player using AI MoveTo and then when it gets to the player it plays an animation and hits them, but when the player dies the enemy still attacks him, how do I make him stop doing that?
GorkaTutorial - Unreal Editor 8_31_2024 4_28_44 PM

Detach from controller pending destroy function also disable movement in character movement component

May have missed your question, if your Wanting the AI to resume patrol or whatever when the player dies, id set an isAlive boolean on your player character class that gets flipped on death, setup a function in your AI to check this and change BB target/set a bb based condition to reroute them to patrol

There are definetly many ways to achieve this but I usually condition such actions on the existence of the player. Maybe you could despawn the player while having a placeholder actor that looks like the remains of the player. And if the abort rules on your behavior tree are set accordingly, you should be fine

(Also if there are other targets that the bots should be moving to or attacking alongside the player, instead of having such a condition, you could set that thing I said on the existence of a valid “target” which would be an object type variable)