**SOLVED** Help (semicolons are evil!)

SOLVED
Hi! My code isn’t working, I will get straight to the problem, here is a screenshot of the error → Imgur: The magic of the Internet

and here is the code to which the error is pointing at:

#pragma strict
var maxFallDistance = -10;
private var isRestarting = false;
function Update ()
{
if (transform.position.y <= maxFallDistance)
{
if (isRestarting == false)
{
ResetLevel ();
}
}
}

function ResetLevel () {
isRestarting = true;
audio.Play ();
Yeild WaitForSeconds (audio.clip.length);
Application.LoadLevel (“Level01”);
}

Help me please!!

Yield
not
Yeild

and use [ code][/ code] tags when pasting code into the forums, sticky at the top of the scripting forum, errors have line numbers, without those tags we can easily see the line numbers…

Yeild WaitForSeconds (audio.clip.length);
should be Yield

Why you got beef with semicolons?

1 Like

Because they hate me!!!

Ahh thank you so much :smile:

Whoops! sorry my bad :slight_smile: thank you for the quick response

Umm that didn’t fix it, it just says the same error (I did save it, before you ask) D:

the code you posted is the BallHealth script? (asking because there doesn’t appear to be anything relating to health in it… :stuck_out_tongue: )

Yep!

audio.Play ();

you don’t appear to have an audio variable declared/initialised… although I wouldn’t have expected a semicolon error for that…

How would I do that in JavaScript?

at the top:

you’d need the audiosource component on the same gameobject… but again, wouldn’t have expected a ; error for that :face_with_spiral_eyes: would have expected a null reference exception etc. :blames unityscript for weird erroring: :stuck_out_tongue:

So would you know any fix on how to get rid of this semicolon error?

Can you post the whole script and use [ code][ /code] UBB tags so its legible?

#pragma strict
var maxFallDistance = -10;
private var isRestarting = false;
function Update ()
{
    if (transform.position.y <= maxFallDistance)
      {
        if (isRestarting == false)
  {
        ResetLevel ();
      }
      }
        }

function ResetLevel () {
   isRestarting = true;
   audio.Play();
   Yield WaitForSeconds (audio.clip.length);
   Application.LoadLevel ("Level01");
}

What are you editing the script in? VS?

Also, in JS with #pragma strict you have to strictly define variables. So “var isRestarting = false;” should be “var isRestarting : bool = false;”…

Theres also no reference to ‘audio’… theres lots of errors in here, your editor probably thinks this is a C# script.

I’m editing it in notepad++

At a bare minimum you should use Monodevelop.

I have installed Monodevelop but that hasn’t fixed anything