Scene change upon reaching a Set Score

Hello, sorry if this a redundant question but I could not find the exact solution I was looking for.

I am attempting to trigger a scene change when the player reaches a high enough score. I am doing this through use of a script attached to some GUIText. My script is as follows.

var Counter : int = 0;

var myLevel : String;

function Update () {

guiText.text = "Score is: "+Counter;
if (Counter : int = 3){


The idea is to trigger the scene once the integer reaches 3. The score-counting part of the script works well, but I have been having trouble with getting the Level load to work (the level load part being the "if (Counter : int = 3){ Application.LoadLevel(myLevel);" and the MyLevel variable).

Any help would be appreciated.

I do not work in javascript but from a quick look I would guess you need to change

if (Counter : int = 3){


if (Counter == 3){

I would guess this from the fact that varibleName : VariableType declares a variable and assigns it a type. In this case an int. Then the following = 3 would assign the value of 3 to the variable. For a comparison you would want two equal signs such as ==.

As a side note. Make sure that myLevel is either the level's index in the build settings or the name of the level. (Either way double check that the level is added to the build settings)