PrintToConsole script isn’t working

After coding the script I get an error message that says
Assets\PrintToConsole.cs(10,35): error CS1002: ; expected


Hi Really,

Welcome to our community! :slight_smile:

Please note, it’s better to copy/paste your code and apply the code fencing characters, rather than using screenshots. Screenshots are ideal for displaying specific details from within a game engine editor or even error messages, but for code, they tend to be less readable, especially on mobile devices which can require extensive zooming and scrolling.

You also prevent those that may offer to help you the ability to copy/paste part of your code back to you with suggestions and/or corrections, meaning that they would need to type a potentially lengthy response. You will often find that people are more likely to respond to your questions if you make it as easy as possible for them to do so.

Regarding your problem, there might be a typo in your script. Have you already compared your code to the Lecture Project Changes which can be found in the Resources of this lecture?

Hope this helps :slight_smile:


See also:

I’m a bit embarrassed to admit that I just forgot a semicolon, but it works!
And I will copy paste my code in the future if I need any help

I’m glad the solution was so simple. Those semicolons are a common source of errors, not just for beginners but also for experienced programmers. :slight_smile:

1 Like

Don’t feel embarrassed @Really, I’ve done the same thing many times.

I’ve even posted my question here, then solved it 5 minutes later. Nothing to feel bad about.

I do have a question for you though, as I had trouble interpreting these messages when I was a beginner:

Do you have a decent understanding of the error messages?

I would like to show you something useful, in case you don’t know. Let’s use your message:
Assets\PrintToConsole.cs(10,35): error CS1002: ; expected

The first thing I look for is the (10, 35). This tells you that Unity believes your problem is on line 10 at position 35, so if you put the cursor on line 10 and arrow to the right 35 times, that is exactly where Unity believes the mistake is located. Knowing this helps immensely!

I don’t normally look up the ‘error CS1002’ part unless I really get stuck, but the ‘CS1002’ is an error code that should be listed in the Unity documentation. That said, there is a list of error code definitions here:

Strangely enough, the CS1002 error code does not seem to be listed at this location. It is what it is, I guess, but this would be where people would usually go to look up the error code definitions.

The message follows by stating ‘; expected’. Of course, I think you know this part already by now.

That said, Unity is trying it’s best to tell you that you left out the semicolon at position 35 on line 10.

I hope this helps. I had to figure it out myself, too. It was frustrating for me to figure out, too, and I feel your pain.

Welcome to GameDev Community!

Game on!

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms