Coroutine is not working

Animation should be played every few seconds but it does not

if (Vector3.Distance(transform.position, enemy.position) <= throwRadius)
                {
                    if (!threw)
                    {
                        animator.SetTrigger("Throw");
                        threw = true;
                    }
                    else
                    {
                        StartCoroutine(Wait());                   
                    }
                }
            }
    IEnumerator Wait()
        {
            yield return new WaitForSeconds(5f);
            threw = false;
        }

animation is still playing without delaying it for a 5 seconds, just one after another.Code is in update func

I’d rework this to remove the coroutine entirely and use a simple countdown field in your class instead. lastThrown would be the countdown field and should start off at 0f (float).

if (lastThrown > 0f) { 
    lastThrown -= 1f * Time.deltaTime; 
}
else if (within distance) {  
    trigger;
    lastThrown = 5f; // preferably replace '5f' with a CONSTANT
}

The snippet above will do the same thing as your coroutine, yet is simpler. I don’t know the overhead that coroutines come with, but I’d think this is certainly optimal too. I only use coroutines in specific circumstances.

p.s. if your animation is still replaying instantly, it’s likely you’ve configured the animation incorrectly. Double check to make sure the animation isn’t set to loop, and test playing the animation just once to start with (adding in some temporary code to play it once in the Start method or something) - make sure the trigger correctly leaves the animation state and returns to another state.

A coroutine is typically it’s own function that can be invoked - not something that is directly placed inside of Update().
_
// increase someInteger by 1 every five seconds.

public int someInteger;
private bool isWaiting;

void Update()
{
    if (!isWaiting)
    {
        StartCoroutine(someCoroutine());
    }
}

private IEnumerator someCoroutine()
{
    isWaiting = true;
    yield return new WaitForSeconds(5);
    someInteger++;
    isWaiting = false;
}