[Solved] Void Error Help!


I have tried making a script from the number wizard game, unfortunately when I try running this script on Unity it will say Error Unexpected symbol - void.

I have expected it too work smoothly .
I have tried putting in } and copying other peoples code but to no avail.
I am working on a Windows 10 with unity 4.6.9 and monodevelop.
I appreciate any help Thanks in advance.

1 Like

Hi @Mike_Haley,

Your error is being caused by the roger input statement that has been started on line 18. The compiler is expecting certain characters to follow this statement and void isn’t it :slight_smile:

For now, you could just comment out line 18 by adding two forward slashes in front of input, e.g. \\ input

Alternatively, deleting that incomplete statement, or finish it off :slight_smile:

After that, the compiler will then moan about something else, the next issue, based purely on your screenshot would be a missing closing brace } to close the Update() method, and then, the same again to close the class.

I hope this helps :slight_smile:

Thankyou very much for your help, this has worked but now there is only one more error
I do not understand what is wrong with my code any help would be much appreciated.
Thank you again.

1 Like

Hi @Mike_Haley,

You’re more than welcome.

Regarding the next error, the compiler is giving you a little bit of guidance here, firstly it’s saying it’s a parsing error, basically, it can’t read your code as it would expect to, could be a number of things that may cause this. The numbers in the brackets (30,57) refer to the line number and column number.

So, have a look around line 30, it may be on that line, or just before it.

Also, post the full code up as your original screenshot doesn’t include these lines :slight_smile:

Thank you yet again unfortunately the script will now not show, all the errors have been dealt with and nothing happens
(sorry to bother you again)
I am in game mode

Hi @Mike_Haley,

It’s no bother at all, this is what our community is all about - taking the time to help each other :slight_smile:

Your code looks good, so the thought I am having at the moment is that maybe your script isn’t attached to a Game Object in the Hierarchy. If it isn’t, create a new Empty Game Object, perhaps name it NumberWizard, then attach the script to it either by dragging and dropping it onto it in the Hierarchy, or, by selecting the NumberWizard Game Object and then clicking on the Add Component button in the Inspector.

Hope this helps, let me know how you get on :slight_smile:

Thank you It is finally working!
If I keep making mistakes like this I might be spending most of my time in the discussions.

1 Like

Hey @Mike_Haley it’s ok, everyone has their own learning curve / journey, so if there is ever something you aren’t sure about or just want to check, feel free to post and someone will help you out.

The community is pretty good at providing constructive feedback on other students games also, so maybe if you put your own story into Text101 or enhance the other course games, maybe pop a post up sharing your game and ask for some feedback.

You will invariably find that over time you will pick up lots of “ahh that was the problem” moments, so, if you happen to see anyone else with a problem that you can help with feel free to hop in and offer.

Really pleased.you got it working and are moving forwards again.

All the best :slight_smile:

1 Like