re-spawning object keeps moving

hello,

I am having a problem respawning an object, every time it respawns it duplicates in the same position and not in the position i want it to. i have tried a few methods to get it to work but they have all failed. what i would like it to do is to respawn a new object whilst keeping the old ones but respawn in a different location.

here is the code

using UnityEngine;
using System.Collections;


public class Button1 : MonoBehaviour {
	public Texture btnTexture;
	public GameObject myPrefab;
	public Texture btnTexture2;
	public Texture btnTexture3;
	public float posx; 
	public float posy;
	public float posz;
		void  Update (){



	}
	void OnGUI() {
		if (!btnTexture) {
			Debug.LogError("Please assign a texture on the inspector");
			return;
		}
		if (GUI.Button (new Rect (135, 10, 125, 125), btnTexture)) {
			Debug.Log ("1");

			 Instantiate (myPrefab, new Vector3(posx,posy,posz), Quaternion.identity);

	
	
	}
		if (GUI.Button (new Rect (285, 10, 125, 125), btnTexture2)) {
			Debug.Log ("2");
		}
		if (GUI.Button (new Rect (475, 10, 125, 125), btnTexture3)) {
			Debug.Log ("3");
		}
	}
}

If you want to keep your old object (just spawned) you can change it’s position istead of destroying it.

You can use a similar function

[SeralizedField] Transform ObjRef;

void MoveAway(Vector3 newPos)
{
   ObjRef.position = newPos;
}

I belive that every time that you spawn an object you change posx, posy and posz manually from editor or by some other scripts before spawning another one. Otherwise is obvious why the object spawn in the same position.