Turrent Spawner spawns in wrong location

For my fpswalker, it has a child object (a blueprint of a turret model) that spawns a turret. The problem is it spawns the turret at the position of the fpswalker and not the child object. The script is attached to the child object....I tested it with a parent child empty gameObject and it worked. So it has something to deal with the fpswalker itself....

var turret : GameObject;
function LateUpdate (){
    if(Input.GetButtonDown ("Fire1")){
        if(GetComponent(gunscript).gunActive){
    var newCoconut : GameObject = Instantiate(turret, transform.position , transform.rotation);

    }
    }
}

you could use this script and then put the script in the fps walker you could also try using this.transform instead of just transform though i don’t know if it would make a difference…

var turret : GameObject;
//set this object as your empty child
var spawnLocation : Transform; 

function LateUpdate (){
    if(Input.GetButtonDown ("Fire1")){
        if(GetComponent(gunscript).gunActive){
            var newCoconut : GameObject = Instantiate(turret, spawnLocation.position , spawnLocation.rotation);
    }
}

Or you could have two children one that is the empty that handles spawning the turret and then the blueprint object at the same exact position that does nothing more than look pretty.

When the script is on the child object, it will use the position / rotation of the child object. Are you sure the child object is at the right position at runtime? When you test in the editor, start your game and switch to the scene view and check where your child object is.