Javascript is crashing unity, 17Lines please take a look.

I don’t know what’s wrong with that script but it makes unity crash.

#pragma strict
var player : Transform;
private var IsMoved: boolean;
private var pos : Vector3;

function Start () {
}

function Update () {
	while(IsMoved == false){
		pos = LevelGeneration.EntrancePosition;
		transform.position = pos;
		if(Vector3.Distance(transform.position,player.transform.position) < 1)
		{IsMoved = true;}
	}

}

(note “LevelGeneration.EntrancePosition” is a static variable from another script.)
Can somebody please help me?

Your while loop is getting into infinity.

Since at start of the loop, IsMoved is false and it will stay false since the position of both game objects is same in that loop and not changing in the first frame itself where this loop is getting called for first time.

You need to restructure your code.