NullReferenceException: Object reference not set to an instance of an object

What’s the problem??

Error at: clone.rigidbody.AddRelativeForce(new Vector3(0f,-5f,0f));

if ((Time.time>nextInst)
		{
			position = new Vector3(x, 20, z);
			nextInst = Time.time+delay;
		
			if((Input.GetMouseButton(0)) )
			{
			
				 clone = Instantiate(prefab,position,transform.rotation) as Rigidbody ;
				if(clone.GetComponent("rigidbody") == true)
				{
					print("Rigidbody");
				}
				 clone.rigidbody.AddRelativeForce(new Vector3(0f,-5f,0f));
			}
		}

I assume that “prefab” is not of type Rigidbody. The type of the prefab must match the type that you are instantiating as, otherwise it’s null. Also this is wrong:

if(clone.GetComponent("rigidbody") == true)

It should be

if (clone.GetComponent<Rigidbody>() != null)

or just

if (clone.rigidbody != null)