How stop the Infinite jump 2d

I’m new coding and c# but I’m trying to make it so the player can only jump once before touching the ground again.
using UnityEngine;
using UnityEngine.InputSystem;

public class PlayerMovement : MonoBehaviour {
    [Header("Important Shit")]
    public Rigidbody2D rb;
    public float speed;
    public bool jumping ;
    public float height;
    public bool grounded ;

    [Header("Controls")]
    public InputAction move;
    public InputAction jump;

    void OnEnable()
    {
        move.Enable();
        jump.Enable();
    }

    void OnDisable()
    {
        move.Disable();
        jump.Disable();
    }


    void Awake()
    {
        jump.performed += context => jumping = true;
        jump.canceled += context => jumping = false;
        
    }

    void Start()
    {
        rb = GetComponent<Rigidbody2D>();  
    }

    void Update()
    {
        float currentheight = 0f;
        rb.velocity = move.ReadValue<Vector2>() * speed;

        if(grounded && !jumping)
        {
            currentheight = height * 2;
            grounded = false;
            jumping = true;

        }
        else
        {
            currentheight = height;
        }
    }

    void OnCollisionEnter2D(Collision2D collision)
    {
        if (collision.gameObject.CompareTag("Ground"))
        {
            grounded = true;
            jumping = false;
            
        }

        
       
    }

    void OnCollisionExit2D(Collision2D collision)
    {
        if(collision.gameObject.CompareTag("Ground"))
        {
            grounded = false;
            jumping = true;
        }
    }
}

@Tyrik10 - You need to modify the Update() method to apply the jump force only when the jumping variable is set to true and the player is grounded. Also, remove the unnecessary code for setting currentheight. Here’s the modified Update() method:

void Update()
{
    rb.velocity = new Vector2(move.ReadValue<Vector2>().x * speed, rb.velocity.y);

    if (grounded && jumping)
    {
        rb.AddForce(new Vector2(0f, height), ForceMode2D.Impulse);
        grounded = false;
    }
}

In the modified code, the player’s horizontal movement is separated from the vertical movement. The jump force is applied only when the player is grounded and the jump action is performed. This way, the player can only jump once before touching the ground again.

Let me know if this gets you closer to an answer.