How do I create a random teleport?

I’ve been making a very simple “slender” type game. All it is, is a sprite following the player. I want it so when the sprite (named The Creature) gets to close to the player, It teleports back to one of three locations. I want the choice of this location to be randomized. I already made 3 empty game objects for the spawn and have made transform variables for each of them. I’m very new to this coding, I’ve used unity itself plenty. I’ve looked everywhere and cannot find a situation similar enough to mine for me to figure it out. Thanks in advance for any help.
(Java script)

var respawnA : Transform;
var respawnB : Transform;
var respawnC : Transform;
var speed : float = 5; //speed of movement
var Target: Transform; //the player it's chasing.
var RespawnArray = new Array("respawnA", "respawnB", "respawnC"); //each of the spawns

function Start () {


}

function Update () {
var MyIndex = Random.Range(0, RespawnArray.length); // the pick of spawns


transform.LookAt (Target); //look at the player
transform.Translate (Vector3.forward * speed * Time.deltaTime); //move at the player

if (Vector3.Distance(transform.position, Target.position) < 1)// when it gets too close, teleport
	transform.position = MyIndex.position; //the location of that spawn.


}

The game runs until the creature gets too close. then it just sticks to the player and spams the console error "MissingFieldException: System.Int32.position
Boo.Lang.Runtime.DynamicDispatching.PropertyDispatcherFactory.FindExtension (IEnumerable`1 candidates)
Boo.Lang.Runtime.DynamicDispatching.PropertyDispatcherFactory.Create (SetOrGet gos)
Boo.Lang.Runtime.DynamicDispatching.PropertyDispatcherFactory.CreateGetter ()
Boo.Lang.Runtime.RuntimeServices.DoCreatePropGetDispatcher (System.Object target, System.Type type, System.String name)
Boo.Lang.Runtime.RuntimeServices.CreatePropGetDispatcher (System.Object target, System.String name)
Boo.Lang.Runtime.RuntimeServices+c__AnonStorey17.<>m__C ()
Boo.Lang.Runtime.DynamicDispatching.DispatcherCache.Get (Boo.Lang.Runtime.DynamicDispatching.DispatcherKey key, Boo.Lang.Runtime.DynamicDispatching.DispatcherFactory factory)
Boo.Lang.Runtime.RuntimeServices.GetDispatcher (System.Object target, System.String cacheKeyName, System.Type[ ] cacheKeyTypes, Boo.Lang.Runtime.DynamicDispatching.DispatcherFactory factory)
Boo.Lang.Runtime.RuntimeServices.GetDispatcher (System.Object target, System.Object[ ] args, System.String cacheKeyName, Boo.Lang.Runtime.DynamicDispatching.DispatcherFactory factory)
Boo.Lang.Runtime.RuntimeServices.GetProperty (System.Object target, System.String name)
UnityScript.Lang.UnityRuntimeServices.GetProperty (System.Object target, System.String name)
"

Random teleporting/organized teleporting

For ultra random:

var xAxis = Random.Range(-9999,9999);
var yAxis = Random.Range(-9999,9999);
var zAxis = Random.Range(-9999,9999);

function Start () {
InvokeRepeating(repeat,0,5);
}

function repeat () {
transform.position.x = xAxis;
transform.position.y = yAxis;
transform.position.z = zAxis;
}

And for organized:

var tp1 : Transform;
var tp2 : Transform;
var tp3 : Transform;

function Update () {
var select = Random.Range(1,4);
if(select == 1)
transform.position = tp1.position;
if(select == 2)
transform.position = tp2.position;
if(select == 3)
transform.position = tp3.position;
}

Theese are just ideas to get you started

thank you so much. For the life of me I couldn’t figure that out myself. I’ll implement that and let you know how that goes!

It works, Thank you so much. 2 hours of hair ripping solved. :smile: