Object reference not set to an instance of an object ERROR

I’m working on a script that will allow me to place blocks like MC. The problem is, when I click, I get the error, “Object reference not set to an instance of an object.”

Here is the code:

var followingObject : GameObject;
var object : Transform;
var Gui : GUITexture;
var On : Texture2D;
var sound : AudioClip;

function Update () {
  var v3T = Vector3(Input.mousePosition.x, Input.mousePosition.y, 3);
  v3T = Camera.main.ScreenToWorldPoint (v3T);
  followingObject.transform.position = v3T;
}

function OnMouseDown () {
  if (Gui.guiTexture.texture == On) {
  var Hit : RaycastHit;
  var LookingDirection = transform.TransformDirection(Vector3.forward);
  Debug.Log("Working 1");
     var GrassBlock : Transform = Instantiate(object, Hit.collider.transform.position + Hit.normal.normalized, Quaternion.identity);
     audio.PlayOneShot(sound);
     }
 }

object is a type, you cannot name your variable “object”. That’s probably the reason why it does not work as intended.

Try renaming it “_object” or “block”, or something along those lines instead.