Problem with jumping

i want my character to only be able to jump, when he is on the ground. However, my code only works like 75% of the time, sometimes just notjing happens when i press space. Here’s my script, but i dont know if the script is even the problem:

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

public class Spieler : MonoBehaviour
{
    private Rigidbody Rigidbody;
    public bool canJump = true;

private void OnCollisionEnter(Collision Collision)
    {
        if (Collision.gameObject.tag == "Ground")
        {
            canJump = true;
        }
    }
 private void OnCollisionExit(Collision Collision)
    {
        if (Collision.gameObject.tag == "Ground")
        {
            canJump = false;
        }
    }
void Update()
    {
        if (Input.GetKeyDown(KeyCode.Space))
        {
            if (canJump == true)
            {
               Rigidbody.AddForce(new Vector3(0, 6, 0), ForceMode.Impulse);
            }
        }
}

I recommend you to use character controller. It will be more convenient when jumping and moving.
But if you still want to try this, i would recommend you to ensure that u collide with the floor properly when land on it.

try changing from “OnCollisionEnter” ->“OnCollisionStay”