When I spawn the player the animation of attack don't work

If I drag the prefab into the scene this works perfectly, but if I spwan the prefab through this code:

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

public class SpawnPoint : MonoBehaviour
{
    public GameObject playerSpawn;

  
    void Start()
    {
        Instantiate(playerSpawn);
    }

   
}

The player moves but when i try to attack the animation don’t work.

The code of attack animation:

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

public class PlayerCombat : MonoBehaviour
{

    public Animator animator;

    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Mouse0))
        {
            Attack();
        }
    }

    void Attack()
    {
        animator.SetTrigger("Attack01");
    }
}

Thank you.