Object Reference Not Set Up As An Instance Of An Object

Full error: NullReferenceException: Object reference not set to an instance of an object
PickUpScript.Update () (at Assets/PickUpScript.js:43)

So this script is meant to pick up and drop items when clicked on. When I pick up the item I get that error. Here’s the script

#pragma strict

var hitObject : GameObject;
var pickupPosition : Transform;
var hold : boolean = false;
var pickableObject : GameObject[];
 
 function Update () {

	if(Input.GetMouseButtonDown(1)) {
	
		var hit : RaycastHit;
			if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), hit)) {
			
				hitObject = hit.collider.gameObject;
					
					if (hitObject.tag == "pickUp") {
					
						var kinematic : Rigidbody;
						kinematic = hitObject.gameObject.GetComponent (Rigidbody);
						hitObject.transform.position = pickupPosition.position;
						hold = true;
						kinematic.isKinematic = false;
						
						
					
					}
			
			
			}
			
			
	
	}
	
	if (hold == true) {
	
		hitObject.transform.position = pickupPosition.position;
	
	}
	
		if (Input.GetMouseButtonUp(1)) {
			kinematic.isKinematic = true;
			hold = false;
		
		}

		if (Input.GetMouseButtonUp(0)) {
		
			Debug.Log ("fire");
		
		}

}

How should I change the script so I don’t get the error?

Thanks in advance.

(Sorry this is like my 5th question today xD)

hii…

Update this code and check u still getting the error.

if (hold == true) {

   if(hitObject)
  {
         hitObject.transform.position = pickupPosition.position;
  }  

}

You might have error in kinematic variable. Declare that variable out of the function. and check condition whether it is null or not.