Script isnt playing death animation

I have a script where you shoot a gun at a enemy the health goes to zero it should play a animation…

However of course its not playing

It just stops all animations all together and just sits there.

Also the floating I am aware of I haven’t figured out how to keep it on the ground yet

using System.Collections;
using System.Collections.Generic;
using UnityEngine;



public class Zombie : MonoBehaviour
{

    public GameObject ThePlayer;
    public float TargetDistance;
    public float AllowedRange = 10;
    public GameObject TheEnemy;
    public float EnemySpeed;
    public int AttackTrigger;
    public RaycastHit Shot;

    void Update()
    {
        transform.LookAt(ThePlayer.transform);
        if (Physics.Raycast(transform.position, transform.TransformDirection(Vector3.forward), out Shot))
        {
            TargetDistance = Shot.distance;
            if (TargetDistance < AllowedRange)
            {
                EnemySpeed = 0.01f;
                if (AttackTrigger == 0)
                {
                    TheEnemy.GetComponent<Animation>().Play("Walking");
                    transform.position = Vector3.MoveTowards(transform.position, ThePlayer.transform.position, EnemySpeed);
                 
                }
            }
            else
            {
                EnemySpeed = 0;
                TheEnemy.GetComponent<Animation>().Play("Idle");
            }
       
        }
        if (EnemyHealth <= 0)
        {
            TheEnemy.GetComponent<Animation>().Play("Death");

            Debug.Log("Died");

        }

        if (AttackTrigger == 1)
        {
            EnemySpeed = 0;
            TheEnemy.GetComponent<Animation>().Play("Attacking");
            Debug.Log("working");
        }
    }
    public int EnemyHealth = 10;

    void DeductPoints(int DamageAmount)
    {
        EnemyHealth -= DamageAmount;
    }

void OnTriggerEnter()
    {
        AttackTrigger = 1;
        Debug.Log("working");
    }

    void OnTriggerExit()
    {
        AttackTrigger = 0;
        Debug.Log("Not working");
    }

}

void Update()
    {
        if (EnemyHealth <= 0)
        {
            TheEnemy.GetComponent<Animation>().Play("Death");
            Debug.Log("Died");
            return; //since enemy is dead...
        }

        transform.LookAt(ThePlayer.transform);
        if (Physics.Raycast(transform.position, transform.TransformDirection(Vector3.forward), out Shot))
        {
            TargetDistance = Shot.distance;
            if (TargetDistance < AllowedRange)
            {
                EnemySpeed = 0.01f;
                if (AttackTrigger == 0)
                {
                    TheEnemy.GetComponent<Animation>().Play("Walking");
                    transform.position = Vector3.MoveTowards(transform.position, ThePlayer.transform.position, EnemySpeed);
           
                }
            }
            else
            {
                EnemySpeed = 0;
                TheEnemy.GetComponent<Animation>().Play("Idle");
            }
 
        }
        if (AttackTrigger == 1)
        {
            EnemySpeed = 0;
            TheEnemy.GetComponent<Animation>().Play("Attacking");
            Debug.Log("working");
        }
    }

Even though I would preffer doing it this way

if (TheEnemy.Health <= 0){   
    if (!Anim.IsPlaying("Death"))//Anim is componen Animation
            {
                Anim.CrossFade("Death");
               TheEnemy.tag = "Untagged";
               GetComponent<Collider>().enabled = false;
            }
return;
}

Thank you so much.

Could you explain why I had to return it for it to play the animation?

because its still calculating the distance it needs to attack…

if (enemy.health <= 0)
{
// is dead
}
else// or just return;
{
// attack, run and do sh*t
}