Cube has double jump and jump is inconsistent.

I am trying to get my cube to jump when i press space. But for some reason the isGrounded glitches and i can double jump even when its in the air. and also its very inconsistent like if i spam space a bit it jumps higher or starts rotating the cube. I am a beginner to unity and don’t know why. any help appreciated.

My code:

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

public class PlayerController : MonoBehaviour
{

    private Rigidbody rb;

    public Vector3 jump;
    public float jumpForce = 2.0f;
    public bool isGrounded;

    public float speed = 0;
    private float movementX;
    private float movementY;
    // Start is called before the first frame update
    void Start()
    {
        rb = GetComponent<Rigidbody>();
        jump = new Vector3(0.0f, 2.0f, 0.0f);
    }
 
    void OnMove(InputValue movementValue)
    {
        Vector2 movementVector = movementValue.Get<Vector2>();
        movementX = movementVector.x;
        movementY = movementVector.y;
    }

    void OnCollisionStay()
    {
        isGrounded = true;
        Debug.Log("GROUDED");
    }

    private void Update()
    {
        if (Keyboard.current.spaceKey.wasPressedThisFrame && isGrounded)
        {
            rb.AddForce(jump * jumpForce, ForceMode.Impulse);
            isGrounded = false;
            Debug.Log("UnGROUNDED");
        }
    }

    private void FixedUpdate()
    {
        Vector3 movement = new Vector3(movementX, 0.0f, movementY);
        transform.Translate(movement/speed);
    }
}

bump

There are a lot of ssues in your code, but I think direct solution to your problem is

using UnityEngine;

public class PlayerController : MonoBehaviour
{

    private Rigidbody rb;

    public Vector3 jump;
    public float jumpForce = 2.0f;
    public bool isGrounded;

    bool jumpRequest;
    void Start()
    {
        rb = GetComponent<Rigidbody>();
        jump = new Vector3(0.0f, 2.0f, 0.0f);
    }

    void OnCollisionEnter()
    {
        isGrounded = true;
        Debug.Log("GROUDED");
    }

    void OnCollisionExit()
    {
        isGrounded = false;
        Debug.Log("UNGROUDED");
    }
    private void Update()
    {
        if (Input.GetKeyDown(KeyCode.Space) && isGrounded)
        {
            jumpRequest = true;
        }
    }

    private void FixedUpdate()
    {
        if (jumpRequest)
        {
            jumpRequest = false;
            rb.AddForce(jump * jumpForce, ForceMode.Impulse);
        }
    }
}