Spawning random objects not working

Hello everyone.
So i managed to spawn random obstacles. But they dont respawn at a random position they always respawn on the same position.
Why is that?

Code:

using UnityEngine;
using System.Collections;

public class Spawner : MonoBehaviour {
	
	public GameObject[] prefabs;
	public float delay = 2.0f;
	public bool active = true;
	public Vector2 delayRange = new Vector2 (1, 2);
	
	// Use this for initialization
	void Start () 
	{
		ResetDelay ();
		StartCoroutine (ObstacleGenerator ());
	}
	
	
	IEnumerator ObstacleGenerator(){
		
		yield return new WaitForSeconds (delay);
		
		if (active) 
		{
			var newTransform = transform;
			
			Instantiate(prefabs[Random.Range(0, prefabs.Length)], newTransform.position, Quaternion.identity);
			ResetDelay ();
		}
		
		StartCoroutine (ObstacleGenerator ());
		
	}
	void ResetDelay(){
		delay = Random.Range (delayRange.x, delayRange.y);
	}
	
}

Thank you

you are setting newTransform to equal the script’s gameobject’s transform every time. instead try setting the location around where you want them to spawn, then adding a random amount to that.

I tryed like this:

Instantiate(prefabs[Random.Range(0, prefabs.Length)], new Vector2(Random.value, Random.value), Quaternion.identity);

Still not random position. They always spawn at the same position