What ';' is required?


Even your script only has 3 lines it has a multipe of the line count errors. Programming languages require you to write an explicit syntax. Also most languages are case-sensitive.

Here are a few points:

  • You definately have way too much semicolons. If the compiler says “semicolon expected” at some point doesn’t mean you should insert one. It could simply mean that after some statement you put something wrong and the compiler just tells you that the statement before need to be finished before you start a new one. In your case you have not a single valid statement, no matter where you put a semicolon.
  • The type “AudioClip” has the wrong capitalisation.
  • It seems you want to declare an array of tyoe AudioClip but since it’s UnityScript you need to use the “var” keyword. Also you don’t have a name for your array.
  • If the array declaration would be right you now assign a single AudioClip to the array variable which doesn’t work. You might wanted to create the array but that’s not necessary since the array is usually filled in the inspector.
  • You just placed an “if-statement” just into your script file. You have to distinguish between code that declares something (like a variable, a method, a type) and code that can be executed. Code that can be executed can only be placed inside of a function / method. An if statement is code that need to be executed.
  • In your if-condition you used “colliding” and “colliderTag” which are unknown identifiers. They simply doesn’t exist.
  • “playoneshot” is also an unknown method. You probably wanted to use PlayOneShot but this belongs to an AudioSource, so you need an AudioSource attached to that gameobject.
  • There’s also not a “random” function. Random.Range is what you probably want, but it needs two parameters, min and max.
  • I guess “audioclip” is your array. However arrays don’t have a “range”, they have a “Length”

All in all i guess you want something like this:

var grassSounds : AudioClip[];

function OnCollisionEnter(collision : Collision){
    if (collision.collider.tag == "grass"){

Not sure how familiar you are with programming, but from the looks of it youre not very experienced. It seems as though you have a semicolon on literally ebery line. You only need them at the end of a statement. On those blank lines, although not technically wrong, you dont need them there.

Anyways, all these random semicolons could cause some odd, potentially inaccurate errors. Try deleting the one at the end of the 4th line (end of the if) and become more familiar with the syntax.

the problem with your code is the fact that you have a semicolon at the end of every line.
Bunny83 seems to be on point with what you’re trying to do.
I suggest the first thing you do is go learn the basics of writing code.
Once you learn more about proper syntax you should be able to avoid problems like this in the future.