🤔

CS0131#

The left-hand side of an assignment must be a variable, property or indexer

You can only assign a value to a variable, property, or indexer.
If you are seeing this error you have likely used the assignment (=) operator by mistake.

Resolution#

Correct the error by using the equality (==) or comparison operators instead:

🟢 Correct#

if (a == b)
{
    // 
}

🔴 Incorrect#

if (a = b)
{
    // 
}
information

If you are comparing two floats using equality, consider using a comparison operator, or Mathf.Approximately to avoid floating-point arithmetic errors.


If you are seeing the error outside of this context, consider the content to the left of the assignment and whether it can logically be assigned to. Rework your code to make the left-hand side a single variable, property, or indexer.