Hey, thank’s for reading. I am currently making a script in Unity 5 with Javascript, and there is an error, and I cannot figure out what’s wrong with my script.
Here’s the error:
Assets/Standard Assets/HorrorGameStuffs/DreamshardsLab.js(27,26): UCE0001: ‘;’ expected. Insert a semicolon at the end.
And here is the script:
var Dreamshard : int = 0;
var dreamshardsToWin : int = 2; //number to win!
var win = false;
function Start()
{
win = false;
}
//Saying if you have 'x' dreamshards, the 'win' state is applied.
function Update ()
{
if (Dreamshard == dreamshardsToWin)
{
win = true;
}
} //trying to say that if win state, then upon entering zone, next level loaded.
if (win == true)
{
function (OnTriggerEnter)
{
if (other.gameObject.tag == "ExitLab")
{
Application.loadedLevel("MainMenu");
}
} ***//Line 27***
}
function OnTriggerEnter( other : Collider )
{
if (other.gameObject.tag == "Dreamshard")
{
Dreamshard += 1;
Debug.Log("A dreamshard was picked up. Total shards = " + Dreamshard);
Destroy(other.gameObject);
}
}
function OnGUI()
{
if (Dreamshard < dreamshardsToWin)
{
GUI.Box(Rect((Screen.width/2)-100, 10, 200, 35), "" + Dreamshard + " Dreamshards");
}
else
{
GUI.Box(Rect((Screen.width/2)-100, 10, 200, 35), "Find the exit.");
}
}
When I double-click the error, it redirects me to line 27 (I’ve marked it for you).
I honestly have no idea why it would want me to add a semicolon… Please help. Thank you so much for your time.