My player character won't play there jumping animation

I have it set so when the player presses the jump button it sets the jump value to true. But for what ever reason it doesn’t do that. it’s get button down so some times he will play the animation on the first frame but go back to his standing idle animation while in the air Until you let go, when you let go the jump variable becomes true because get button up also sets jump to true. Both have an animation Boolean attached to them that should be set to true, and the jump should only be set to false when the player hits the ground. The problem is that neither jump Boolean or the animation Boolean become true when you press the jump button and I have no idea why this is the case.

here is my code in it’s entirety there is also a CharacterController script but I didn’t code that. Any help is appreciated.

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

public class PlayerMovement : MonoBehaviour
{

public CharacterController2D controller;

public float runSpeed = 27f;
public Animator animator;

public Transform tran;

float gravityValue;

public float riseGravity = 3;
public float fallGravity = 6;

public Rigidbody2D rb;
public float horizontalMove = 0f;
public bool jump = false;
public bool crouch = false;
public float crouchTime = 0.35f;
public bool hitStun = false;
public bool invincibility = false;
public float hitTimer = 0.1f;
public float health = 10;

public string direction = "right";

public float knockBack;
public float KnockBackCount;
public float knockBackLength;
public bool knockFromRight;

void Start()
{
    gravityValue = 3f;
   
}

void Update()
{
    GetComponent<Rigidbody2D>().gravityScale = gravityValue;

    //Collider2D[] rightHitBox = Physics2D.OverlapBoxAll(rightPoint.position, hBoxSize, Player);

    //Collider2D[] leftHitBox = Physics2D.OverlapBoxAll(leftPoint.position, hBoxSize, Player);

    if (KnockBackCount <= 0 && hitStun == false)
    {
        GetComponent<Weapon>().canShoot = true;
        horizontalMove = Input.GetAxisRaw("Horizontal") * runSpeed;

        if(horizontalMove == 27)
        {
            direction = "right";
        }

        else if (horizontalMove == -27)
        {
            direction = "left";
        }

        animator.SetFloat("Speed", Mathf.Abs(horizontalMove));
        animator.SetBool("takinDamage", false);

        if (Input.GetButtonDown("Jump"))
        {
            jump = true;
            animator.SetBool("IsJumping", true);

        }

        if (Input.GetButtonUp("Jump"))
        {
           jump = true;
          animator.SetBool("IsJumping", true);
            gravityValue = fallGravity;
        }

       

        if (Input.GetKeyDown("s") && crouchTime > 0)
        {

            crouch = true;

        }

        if (crouch == true)
        {
            crouchTime -= 1 * Time.deltaTime;

            if (crouchTime <= 0)
            {
                crouchTime = 0;

            }
        }
        if (crouchTime == 0)
        {
            crouch = false;
            crouchTime = 0.35f;
        }

       /* if (jump == true)
        {
            animator.SetBool("IsJumping", true);
        }*/
    }
     
    else
    {
        if (knockFromRight)
            rb.velocity = new Vector2(-knockBack, 0);
        if (!knockFromRight)
            rb.velocity = new Vector2(knockBack, 0);
        KnockBackCount -= Time.deltaTime;
    
    }
    if (hitStun == true)
    {
        GetComponent<Weapon>().canShoot = false;
        animator.SetBool("takinDamage", true);
        
        Hit();
    }

    

    if (health < 1)
    {
        Die();
    }
}

public void OnLanding()
{
    animator.SetBool("IsJumping", false);
    gravityValue = riseGravity;

}

private void OnTriggerEnter2D(Collider2D hitInfo)
{
    enemyBullet ebullet = hitInfo.GetComponent<enemyBullet>();
    hitTimer = 0.2f;
    

    if (ebullet != null && invincibility == false)
    {
        health = health - 1.5f;
        hitStun = true;
        invincibility = true;
      
       // animator.SetBool("IsJumping", false);
      //  gravityValue = 10f;

       /* if (direction == "right")
        {
            horizontalMove = -25;

            // rb.AddForce(transform.right * pushPower);
        }
        if (direction == "left")
        {
            horizontalMove = 25;

            // rb.AddForce(transform.right * pushPower);
       }*/
    

    }

}



public void Die()
{
    Destroy(gameObject);
}

public void Hit()
{
  

    hitTimer -= 1f * Time.deltaTime;

    if (hitTimer <= 0)
    {
        hitTimer = 0;
    }

    if (hitTimer == 0)
    {
        hitStun = false;
        invincibility = false;
       
        

    }

}

public void OnCrouching(bool isCrouching) 
{
    animator.SetBool("IsCrouching", isCrouching);
    
}

  private void FixedUpdate()
{
    controller.Move(horizontalMove * Time.fixedDeltaTime, crouch, jump);
    jump = false;    
}

}

look at the jump animation on the side when you play, make sure that if it needs to loop you loop it and if its leaving too early check the leave time