Collider 2d not working

Basically I made a box collider gameobject which is being enable and disabled by the animation.
The problem is that a have a enemy which walks towards player when it is in range it plays attack animation. Because of the animation the hitbox is enabled first and disabled again and it applies damage to the player.
But the problem is if the player doesn’t do anything and just stands there the animation keeps playing the hitbox is enabled and disable again but it doesn’t apply the damage.
It is like the onTriggerEnter Function is not working when the player position isn’t changed at all , even if the hitbox is disabled n then enabled again.

Try using

void OnCollisionStay(Collision collision)
    {
        
    }

It gets called every frame for each collider that is touching it.
Although it would be easier from your enemy script to call say an event on the player that damages it for example:
In your enemy have:

    void AttackPlayer()
    {
        //Play my animation
        GameObject player = GameObject.Find("Player");
        player.GetComponent<HealthScript>().takeDamage(20);
    }

In your player have

    void takeDamage(int amount)
    {
        health -= amount;
    }