Why does this only activate on the second hit?

So I’m just making a basic fighter game (mortal kombat esk) and my attack only registers on the second hit, whether it’s on or off an enemy.

Fighting Game

This is the code put on the hitbox for the attack:

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

public class Player1AttackOne : MonoBehaviour
{
    public bool attackOneHit = false;
    // Start is called before the first frame update
    void OnCollisionEnter2D(Collision2D collision2D)
    {
        attackOneHit = true;
    }
}

This is the code for the combat:

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

public class PlayerCombat2D : MonoBehaviour
{

    public Animator animator;

    public Player1AttackOne player1AttackOneScript;
    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            AttackOne();
        }
    }
    void AttackOne()
    {
        //Play AttackOne animation
        animator.SetTrigger("Attack_One");
        //Detect other players in range of AttackOne hitbox
        if (player1AttackOneScript.attackOneHit == true)
        {
            Debug.Log("Passed to PlayerCombat2D");
            player1AttackOneScript.attackOneHit = false;
        }
    }
}

Ensure that the collision is with the desired target (in this case, an enemy). This will help to ensure that the attack hit is properly registered and that the attackOneHit flag is set correctly.

public class Player1AttackOne : MonoBehaviour
{
    public bool attackOneHit = false;

    private void OnCollisionEnter2D(Collision2D collision2D)
    {
        if (collision2D.gameObject.CompareTag("Enemy")) // Check if the collision is with an enemy
        {
            attackOneHit = true;
        }
    }
}

The code was running quicker than the animation and the collision is tied to the animation. So moving the if check into the update log makes sure whenever the collider comes online it will deal the damage at that instant.