Bullet Spawning Problem

I’m trying to get a bullet to spawn at the location of my game object called “BULLETSPAWN” with the same rotation. I’m trying to use the code:

var bulletPrefab : Transform;

function Update () {
  if(Input.GetButtonDown("Fire1"))
  {
    var bullet =  Instantiate(bulletPrefab,GameObject.Find ("BULLETSPAWN"),Quaternion.identity); 
  }
}

But I get the error:

Assets/BULLETSHOOT.js(13,28): BCE0023: No appropriate version of ‘UnityEngine.Object.Instantiate’ for the argument list ‘(UnityEngine.Transform, UnityEngine.GameObject, UnityEngine.Quaternion)’ was found.

Any suggestions?

try with

var bullet = Instantiate(bulletPrefab,GameObject.Find (“BULLETSPAWN”).transform.position,Quaternion.identity);

The second argument is the position but you are passing the whole game object hence the error.

Also if bulletspawn is a child of the obejct use:

var bullet = Instantiate(bulletPrefab,transform.Find (“BULLETSPAWN”).transform.position,Quaternion.identity);

It will look inside the object instead of going through all objects in the game. Way faster.