Roll the Ball jump,Roll a ball jump

I’m very new to unity, and started following the unity roll a ball tutorial, and wanted to expand my game by making the charachter jump. I managed to figure out how to do it, and now i want it to only be ale to jump while touching the tag “ground” i put together a script but its not working, can anybody help me with that?
This is my complete script.

The lines of the code where i try and let the ball only jump when touching the ground, starts with

void OnColliderEnter(Collider other)

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
using TMPro;

public class PlayerController : MonoBehaviour
{
    public float speed = 20;
    public float jumpForce = 7;
    public TextMeshProUGUI countText;
    public GameObject TextWinObject;

    private Rigidbody rb;
    private int count;
    private float movementX;
    private float movementY;

    void Start()
    {
        rb = GetComponent<Rigidbody>();
        count = 0;
        SetCountText();
        TextWinObject.SetActive(false);
    }

    void OnMove(InputValue movementValue)
    {
        Vector2 movementVector = movementValue.Get<Vector2>();
        

        movementX = movementVector.x;
        movementY = movementVector.y;
    }

    void OnColliderEnter(Collider other)
    {
        if (other.gameObject.CompareTag("Ground"))
        {
            if (Input.GetKeyDown(KeyCode.Space))
            {
                rb.AddForce(Vector3.up * jumpForce, ForceMode.Impulse);
            }
        }
    }
   void FixedUpdate()
    {
        Vector3 movement = new Vector3(movementX, 0.0f, movementY);
        movement = movement.normalized * speed;
        rb.AddForce(movement);
    }
    void Update()
    {

    }

    void SetCountText()
    {
        countText.text = "Coins count: " + count.ToString();

        if (count >= 12)
        {
            TextWinObject.SetActive(true);
        }
    }

        void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.CompareTag("PickUp"))
        {
            other.gameObject.SetActive(false);
            count = count + 1;
            SetCountText();
        }
    }
}

@unity_D387A42D2FFDB5B79FE1
OnColliderEnter: happens in the first frame that two objects with colliders (one must have a rigid body) touch each one

Input.GetKeyDown: happens only in the exact frame that you have pressed the button

This code probably is working but will only work if you press “Space” in the same frame that you touch the ground.

Try a different approach, do the button verification in update and only jump if you aren’t already jumping. Something like that

using System;
using UnityEngine;

public class Ball : MonoBehaviour
{
    private bool isGround = false;
    
    private void Update()
    {
        if (Input.GetKeyDown(KeyCode.Space)) // Have pressed space?
        {
            if (isGround) // am i in ground?
            {
                Jump();
                isGround = false;
            }
        }
    }

    private void OnCollisionEnter (Collision other)
    {
        if (other.gameObject.CompareTag("Ground")) // I'm touching ground for first time
        {
            isGround = true;
        }
    }
    
    private void Jump()
        => rb.AddForce(Vector3.up * jumpForce, ForceMode.Impulse);
}