- Home /
Unity always gives me errors
When i write a script no matter what it always says unexpected symbol or parsing error or both but when i remove the symbol it says expecting symbol and the process repeats i tried a different script editor and it still failed! with the parsing error i remove the curly bracket and it gives me expecting symbol { so i don't know what to do can anyone help??
This kind of error is very common to beginners in program$$anonymous$$g.
You surely have left a semi-colon somewhere or added one in the wrong place (after condition for example, ...)
When you have this kind of problem, start by commenting the entire code of each function. See if the error is still there. Progressively, remove the comments, function by function and see when the error appears. Then, repeat the process with your main "blocks" of code inside your function.
Copy-paste your code as a comment (with the 101010 button), somebody will surely see where the problem is.
Answer by Erestyn · Jun 19, 2015 at 07:54 AM
Without seeing your code we can't really say for definite, but when you receive an error like that, it's usually because you've missed a parenthesis/brace/etc, somewhere. You'll usually come across these when you're defining controls eg:
if (Input.GetKeyDown (KeyCode.UpArrow) {
// do something
}
That would return a syntax error ("Unexpected '{'") because I did not close the first parenthesis. In this instance, deleting the character that is reference in the error would result in more syntax errors - exactly as you describe. So the fix would be to close that parenthesis like so:
if (Input.GetKeyDown (KeyCode.UpArrow)) {
// do something
}
My suggestion would be to double check your code and make sure that all brackets, braces etc. are closed, and that all semi-colons are where they should be.
Double click on the stacktrace (the error messages in the console) to be taken directly to the line that's causing the problems.
Edit: As Helium rightly points out, the stacktrace will not always take you directly to the line as I mentioned. Depending on how your code is set up, it could be a few lines above where you've been taken. Be sure to look everywhere for any unclosed braces etc.
Be careful, when you are taken to the "line that's causing the problems", the problem is not always where we expect, but sometimes few lines above !
A very good point, Helium, and one that has caught me out many times in the past... and will evidentally will continue to do so in the future!
Your answer
![](https://koobas.hobune.stream/wayback/20220613201145im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Parser Error Unexpected symbol `m_MovementAudio' 1 Answer
Problem with the LOD system 1 Answer
C# Parsing Error 1 Answer
unexpected symbol `public´ 1 Answer