bullet issue

hay guys umm ive got an error with my code but ive been playing with it and i dnt quite understand what wrong :frowning: its say the prefab i want the instantiate is null

var bullet:Rigidbody;
var bulletspeed:int;



function Start () {

}

function Update () {
                     
        if (Input.GetButtonDown("Jump"))
       {
        if (Input.GetKeyDown(KeyCode.Space)){
         var bullet: Rigidbody;
         bullet = Instantiate(bullet,transform.position,transform.rotation);
}
}
}

no, this is a mess.

hereโ€™s the script, fixed with notes. Make sure you read it and understand what is happening :

// this is the bullet that is copied and cloned
// it need to be a prefab with a rigidbody
// it needs to then be dropped here in the Inspector
var bulletPrefab : Rigidbody; 

// this is the force applied when the bullet is instantiated
var initialForce : float = 200.0;

function Start () {

}

function Update() 
{
    // check if Jump OR Space has been pressed
    // OR is written like this ||
    // e.g. if ( something == 1 || anotherthing == 2 ) 
     
    if ( Input.GetButtonDown("Jump") || (Input.GetKeyDown(KeyCode.Space) )
    {
        var bulletClone : Rigidbody; // this is the clone of the bullet
        bulletClone = Instantiate( bulletPrefab, transform.position, transform.rotation );
        
        // push the bullet when it is created ** note ForceMode.Impulse
        bulletClone.AddForce( bulletClone.transform.forward * initialForce, ForceMode.Impulse );
    }
}

I suggest you follow this video series, they are only about 5 mins each, and a great start to learning how to use Unity, components and scripts.

Start at the bottom and work up : Unity 3D Student - 3d Modelling

Start at the bottom and work up : Unity 3D Student - 3d Modelling

this is the YouTube link for the above as one playlist : Unity Tutorials - Essentials 00 - Projects - Unity3DStudent.com - YouTube

the Unity Wiki : http://wiki.unity3d.com/index.php/Tutorials

A list of resources : How can I start learning Unity fast? ( List Of Tutorials ) - Unity Answers

http://forum.unity3d.com/threads/132628-How-to-help-the-Absolute-Beginner