Characters can jump twice, although it checks is character grounded

Here is my code:

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

[RequireComponent(typeof(Rigidbody))]
public class PlayerMovementScript : MonoBehaviour
{
    public Vector3 jump;
    public float jumpForce = 2.0f;

    public bool isGrounded;
    Rigidbody rb;
    void Start()
    {
        rb = GetComponent<Rigidbody>();
        jump = new Vector3(0f, 2f, 0f);
    }

    private void OnCollisionStay(Collision collision)
    {
        isGrounded = true;
    }

    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Space) && isGrounded)
        {
            rb.AddForce(jump * jumpForce, ForceMode.Impulse);
            isGrounded = false;
        }
    }
}

You can jump only two times

Are you saying you can jump twice in a row? (ie, tap space twice and it double jumps) or that you can jump once, land, jump a second time, land and then it breaks?

I jump, then isGrounded turns into false for a moment, then it turns back to true, then i jump again, isGrounded turns into false and it doesn’t turns into true until i get on the ground

If it’s turning back to true, it’s because before your jump actually moves your character away from the ground, OnCollisionStay is triggering and turning it back to True would be my guess.

You can verify this with some Debug calls.

Yes, I dealt with a similar problem recently. When the player presses the jump button you are setting isGrounded to false but the character is still on the ground at that point, so your ground check is setting it right back to true.

In my case, I simply had my script wait a few frames after jumping before it resumed ground checking.