NullReferenceExeption on my gun

Hi guys. I found this tutorial and updated the script but my gun does not fire.

using UnityEngine;
using System.Collections;

public class Shoot : MonoBehaviour

{

    public GameObject ammoPrefab;
private Transform myTransform;

// Use this for initialization
void Start ()
    {

}

// Update is called once per frame
void Update () 
{
	if (Input.GetMouseButtonDown (0))
		Debug.Log("Pressed Left Click.");
	{
		spawnAmmo ();
	}
}

void SetInitialReferences ()
{
	myTransform = transform;
}

void spawnAmmo()
{
	Instantiate(ammoPrefab,myTransform.TransformPoint(0,0,0.5f),myTransform.rotation);
}

}

It spams my console with:

NullReferenceExeption: Object reference not set to an instance of an object Shoot.spawnAmmo () (at Assets/Scripts/Shoot.cs:31)

I am a beginner so I do not know what to do. Any help would be appreciated :smiley:

Change your update method to this :

void Update () 
     {
         if (Input.GetMouseButtonDown (0)) {

             Debug.Log("Pressed Left Click.");        
             spawnAmmo ();
         }
     }