Can't Instantiate an object at the clicked position.,I can't Instantiate an Object at the clicked position. I am trying to make a minecraft game.

Here is my code:
{
public GameObject block;

    // Start is called before the first frame update
    void Start()
    {

    }

    // Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            var mousePos = Input.mousePosition;
            var objectPos = Camera.main.ScreenToWorldPoint(mousePos);
            Instantiate(block, objectPos, Quaternion.identity);
        }

    }
}

I keep getting an error that says "NullReferenceException: Object reference not set to an instance of an object.

You don’t have a Game object assigned to block. The script should look like this

// Start is called before the first frame update
  public GameObject block;

     void Start()
     {
 
     }
 
     // Update is called once per frame
     void Update()
     {
         if (Input.GetMouseButtonDown(0))
         {
             var mousePos = Input.mousePosition;
             var objectPos = Camera.main.ScreenToWorldPoint(mousePos);
             Instantiate(block, objectPos, Quaternion.identity);
         }
 
     }