Jump Max Height?

Hello, so i’m currently learning unity and scripting but i can’t seem to find a way to max the height a object can jump. This is my script atm and i know its very plain lol.This is still my first try tbh.

using UnityEngine;
using System.Collections;

public class Cube : MonoBehaviour {

    public float moveSpeed;
    // Use this for initialization
    void Start ()
    {
        moveSpeed = 5f;
    }
   
    // Update is called once per frame
    void Update ()
    {
        if(Input.GetKeyDown(KeyCode.Space)){
            GetComponent<Rigidbody>().velocity = Vector3.up * moveSpeed;
   
        }   
        transform.Translate (moveSpeed*Input.GetAxis("Horizontal") * Time.deltaTime, 0f,moveSpeed * Input.GetAxis("Vertical") * Time.deltaTime);
    }
}

Just to point you in what I think is the right direction, I’d recommend not trying to set the velocity of a rigidbody manually. Instead, you should AddForce to the rigidbody. If you apply that force only in a single frame (such as how you’re currently setting velocity on KeyDown), and most likely only if you detect the player is on the ground, you can adjust the force to get the player to the height you want.

More complex approaches would allow you to hold down the Space button to jump heigher, which means applying additional force in other frames, but this should be a good start.