#pragma strict
var maxFallDistance = -10;
var level = Level 2;
function Update ()
{
if (transform.position.y <= maxFallDistance)
{
Application.LoadLevel = level;
}
if (Input.GetKeyDown(KeyCode.R))
{
Application.LoadLevel = level;
}
}
I keep getting this message:
Assets/scripts/Respawn.js(4,18): UCE0001: ‘;’ expected. Insert a semicolon at the end.
There’s a few things wrong:
var level = Level 2;
That is the source of your error, I assume you want a string there. So it should be changed to:
var level = "Level 2";
The quote block indicates that it is a string, without it the compiler will get confused as to what you want.
There is a second issue, you are assigning to functions rather then calling them lines 10 and 14 should look more like this:
Application.LoadLevel(level);
That’s known as a method call, you are passing the level variable into the function which in this case will make the Application load the scene that is named “Level 2”, which is you are looking for.