How do I stop my character from jumping in midair?

I want to stop my character from jumping in mid air, so i can only jump once off the ground… can anyone help? This is my script.

public class NewBehaviourScript : MonoBehaviour
{

public float jumpforce;
public float moveSpeed;


// Start is called before the first frame update
void Start()
{
    moveSpeed = 1f;    
}

// Update is called once per frame
void Update()
{
   
    transform.Translate(moveSpeed*Input.GetAxis("Horizontal")*Time.deltaTime,jumpforce*Input.GetAxis("Jump")*Time.deltaTime, moveSpeed*Input.GetAxis("Vertical")*Time.deltaTime);   
}

soo… what would that look like?

So you could do something like this, and you would need to make sure you create a Tag for all of your “Ground” assets in your game to “Ground” as per the collision detection at the bottom of the script.

using UnityEngine;

public class NewBehaviourScript : MonoBehaviour
{
    [SerializeField] float jumpforce = 2f;
    [SerializeField] float moveSpeed = 1f;
    bool isGrounded = true;

    // Update is called once per frame
    void Update()
    {
        //Move player along the X and Z axis
        transform.Translate(moveSpeed * Input.GetAxis("Horizontal") * Time.deltaTime, 0f, moveSpeed * Input.GetAxis("Vertical") * Time.deltaTime);

        //Checks if player is grounded and if "Jump" key/button has been pressed
        if (isGrounded && Input.GetAxis("Jump") > 0f)
        {
            //Moves player in Y axis
            transform.Translate(0f, jumpforce * Input.GetAxis("Jump") * Time.deltaTime, 0f);

            //Sets grounded to false, so that jump can not be done again, until player hits the ground
            isGrounded = false;
        }
    }

    //Is called whenever player collides with something
    void OnCollisionEnter(Collision collision)
    {
        //Checks if collision was with a game object with "Ground" tag, if so, sets grounded to true
        if (collision.gameObject.tag == "Ground")
        {
            isGrounded = true;
        }
    }
}