Null Reference Exception objectreference not set to an instance of an object

please help me. i am beginner in unity.
i getting this error when i press fire button
“Null Reference Exception : object reference not set to an instance of an object”

public var bulletPrefab : Transform; 
public var bulletSpeed : float = 20000;  
function Update()
       if(Input.GetButton("Fire1")) {
    if(!bulletPrefab || !bulletSpeed){
	var bulletCreate = Instantiate(bulletPrefab, GameObject.Find("SpawnPoint").transform.position,Quaternion.identity);    
	bulletCreate.Rigidbody.AddForce(bulletCreate.transform.Forward * bulletSpeed);

tell me where is problem and what i have to do.

I can only guess that the error is on the Instantiate line, make sure there really is a G.O. named SpawnPoint (case matters) in the scene. And you have assigned bulletPrefab in the Inspector

First of all fix the type of the variable bulletCreate:

var bulletCreate : GameObject = Instantiate(...) as GameObject;

Then, note that the correct typo is rigidbody (to get the component) not Rigidbody:


But make sure that the prefab does have a rigidbody component. If not, you can add it to the prefab or by code:

var body : Rigidbody = bulletCreate.AddComponent(Rigidbody);