• Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Windows Unexpected unary operator = (Solved)


Hi I'm new to GMS2. I was watching this tutorial video
at around 8:35 I had to stop because of this warning which prevented me from running the game.
I have no idea what i did wrong and don't know how to progress.



I believe you just need a space between the five and the negative sign (possibly also the plus). In general, you should use spaces around your operators (+, -, and so on) but it normally won't cause problems. Here though, because - is both minus and negative, the lack of spaces means it is interpreted as a negative sign making that line a bad line of code.

You're also missing parenthesis after the if statement. And you should be using brackets and at least indenting after them as well. You can safely exclude brackets for only a single line, but you should still indent. It will make your code more readable and prevent unintentional errors.

I think all three of the issues I see here are caused by not following some basic code formatting guidelines, which in this case have actually caused errors. I would pay more attention to the actual style and formatting techniques Friendly Cosmonaut uses in these tutorials and try to follow those as well.
This shouldn’t raise a parser error!! Strange! Try formatting or code correctly, adding braces and parentheses to the if statements


Okay I added the spaces and parentheses and the warnings went away. I'll make sure to keep a closer eye on the formatting. Thanks guys