Why cant i instantiate my ship? Error NullReferenceException: Object reference not set to an instance of an object.

Im sorry if its obvious, im pretty new to this.
basically when the ship moves to far to the right or left it runs into warp or warp2.
when it collides i want it to instantiate to the other warp. but i keep getting the
Error NullReferenceException: Object reference not set to an instance of an object.

CODE:

var warp : GameObject;
var warp2 : GameObject;
var ship : GameObject;

function OnTriggerEnter2D(obj)
{
  var name = obj.gameObject.name;

  if(name == "barrier1"){
    Destroy(gameObject);
    Instantiate(ship, warp.position, Quaternion.identity);
  }

  if(name=="barrier"){
    Destroy(gameObject);
    Instantiate(ship, warp2.position, Quaternion.identity);
  }
}

Hi, I think you forgot to declare the collider type on the function OnTriggerEnter

It should be like this:

function OnTriggerEnter2D (other: Collider2D)
{
}

Make sure that ship, warp, and warp2 are being set and are not null. It is highly likely that one of these variables is null, hense the NullReferenceException. (Learn to read exceptions, they give you a lot of information)