OnTriggerEnter to Destroy Objects not working Correctly

I was making a script meant to destroy both the player and the object the script was attached to and then instantiate and object to replace them both,i was playing around with it for awhile and it worked separately(the objects would get destroyed,object was instantiated)but when i put the script together it would not destroy the player object so there would be 2 players on screen at once.whats the matter

var prefab : Transform;

function OnTriggerEnter (other : Collider) {

Destroy(other.gameObject);

Destroy(this.gameObject);

Instantiate (prefab);
}

also i dont know how to instantiate on the tagged “Players” position and rotation, but you dont need to bother if you dont want, i can figure that out on my own

Check that the object entering the trigger is a player first:

function OnTriggerEnter(other : Collider){
        if (other.transform.tag == "Player" || other.transform.name == "Player") {
            Destroy (other.gameObject);
        }
    
        Destroy (this.gameObject);
    }