- Home /
"Expressions in statements must only be executed for their side effects." ERROR.
I'm getting an "Expressions in statements must only be executed for their side effects." error. What am I doing wrong?
Answer by runevision · Jul 27, 2010 at 08:24 AM
It means you have a statement in your code that doesn't DO anything - it doesn't alter any state and thus doesn't have any effect on anything. That is seen as an error.
One example of this could be if you have a line like this (where MyFunction is a function declared elsewhere):
function Update () {
MyFunction;
}
In this code there is a statement which just states the reference to MyFunction but doesn't do anything with it. If you wanted to call the function, you should remember the paranthesis:
function Update () {
MyFunction();
}
Now the code actually calls MyFunction, so it's not seen as a coding error anymore.
Thanks. Really like your locomotion system by the way :D
What if there is a period in the middle of the function?
Answer by Novodantis 1 · Dec 03, 2010 at 03:19 PM
An additional example that's not a function missing brackets:
I've been stuck with this error for accidentally putting the statements of a For loop in the wrong order. Due to the rarity of the traditional For(Intialisation;Condition;Increment) structure in my code, (and lack of syntax reference in the help file) this elementary error took a while to spot.
Placing my order as For(Intialisation;Increment;Condition), it tried to treat a condition as a change. Which is how I think I got this error.
Your answer
Follow this Question
Related Questions
Whats wrong with this script? 1 Answer
Application.Quit 2 Answers
I have an error while building the game 1 Answer
Desintergrate Enemies on Dying 4 Answers
I got a major question 1 Answer