Instantiate/Destroy in same Script

Is it possible to Instantiate Prefab in the same Script before it was Destroyed?

Here is what I am trying to do but so far it somehow creates clones inside old object and doesnt change position.

var Target5 : GameObject;
var Posx = Random.Range (-10, 10);

function OnTriggerEnter (other : Collider) 
{

if (other.gameObject.CompareTag ("projectile")) 
	{
	Instantiate (Target5, Vector3(Posx,5,0), Quaternion.identity);
	Destroy(other.gameObject);
	Destroy(gameObject);
	}
}

Destroy doesn’t take effect until the end of the frame. All code in a function will run regardless of any Destroy statements. (DestroyImmediate is another story.)

It’s not a good idea to depend on the declaration section to initialize vars. Put your Random.Range just before the Instantiate.