Unity won't let me edit variable in inspector

So I was watching the Brackey’s tutorial on Prefab shooting, and I wrote down the script:

function Update () {

	var bullet : Rigidbody; 
	var Speed = 20; 

	if (Input.GetMouseButtonDown(0)) 
	{
		var clone = Instantiate(bullet, transform.position, transform.rotation); 
		clone.velocity = transform.TransformDirection(Vector3 (0, 0, Speed)); 

		Destroy (clone.gameObject, 3.0); 

	}

the variables “bullet” and “speed” aren’t showing up in the inspector window in Unity. The game won’t work unless I drag the gameobject (the bullet) into the rigidbody slot. Do I need to do a GetComponent.; in function Start ()? Will that work better?

My UnityScript isn’t so good, but I’d say you need to take them out of the Update scope, and make them public.

If memory serves me correctly, “var” as it is is private.

You need to add public infront of it.

So, “public var bullet : Rigidbody” etc.

Your var is in the Update’s scope.

Move it outside of Update.

Change this:

function Update () {
 
     var bullet : Rigidbody; 
     var Speed = 20; 
     [...]
}

To This:

var bullet : Rigidbody; 
var Speed = 20; 

function Update () {
     [...]
}