How to set up the attack using x button in unity 2023?

Hi, I am trying the make the character attack using the x button on my keyboard but so far nothing happens when i press the x button.

So how can i set it up on the animator tab then write it on my C# script.

public class Eddy : MonoBehaviour
{
    private CharacterController controller;
    private Animator anim;
    private Vector3 moveDirection = Vector3.zero;

    public float gravity = 20.0f;
    public float jumpForce = 10.0f;
    public float speed = 50.0f;
    public float turnSpeed = 50.0f;

    public GameObject runFacevar;
    public GameObject jumpFacevar;
    public GameObject idleFacevar;

    private bool isAttacking = false;

    // Start is called before the first frame update
    void Start()
    {
        controller = GetComponent<CharacterController>();
        anim = gameObject.GetComponentInChildren<Animator>();

        runFacevar = GameObject.Find("/Eddy_idle/Armature.001/Root bone/Spine 1/Spine 2/Neck/GEOfacerun");
        jumpFacevar = GameObject.Find("/Eddy_idle/Armature.001/Root bone/Spine 1/Spine 2/Neck/GEOfacejump");
        idleFacevar = GameObject.Find("/Eddy_idle/Armature.001/Root bone/Spine 1/Spine 2/Neck/GEOfaceidle");
    }

    // Update is called once per frame
    void Update()
    {
        if (controller.isGrounded && Input.GetKey("up"))
        {
            anim.SetInteger("AnimPar", 1);
            moveDirection = transform.forward * Input.GetAxis("Vertical") * speed;
            float turn = Input.GetAxis("Horizontal");
            transform.Rotate(0, turn * turnSpeed * Time.deltaTime, 0);

            runFacevar.SetActive(true);
            idleFacevar.SetActive(false);
            jumpFacevar.SetActive(false);
        }
        else if (controller.isGrounded)
        {
            anim.SetInteger("AnimPar", 0);
            moveDirection = transform.forward * Input.GetAxis("Vertical") * 0;
            float turn = Input.GetAxis("Horizontal");
            transform.Rotate(0, turn * turnSpeed * Time.deltaTime, 0);

            runFacevar.SetActive(false);
            idleFacevar.SetActive(true);
            jumpFacevar.SetActive(false);
        }

        if (Input.GetButtonDown("Jump") && controller.isGrounded)
        {
            anim.SetInteger("AnimPar", 2);
            moveDirection.y = jumpForce;

            runFacevar.SetActive(false);
            idleFacevar.SetActive(false);
            jumpFacevar.SetActive(true);
        }
        if (Input.GetKeyDown(KeyCode.X))
        {
            Attack();
        }



        controller.Move(moveDirection * Time.deltaTime);
        moveDirection.y -= gravity * Time.deltaTime;
    }
    private void Attack()
    {
        anim.SetTrigger("Attack");
    }

    
}

The code looks straight forward so i’d say it’s probably a problem with the way you setup the animation links/conditions , have the game and the animator both open and focus on the flow of the animation tree and how it does the transitions.