Error : Expressions in statements must only be executed for their side-effects

I’ve got a script like so to record the x-position of my character,

var xpos : float;

function Update () {
xpos == transform.position.x;
	if(Input.GetKeyDown("q")){
		print(xpos);
	}
}

But I keep getting the error “Expressions in statements must only be executed for their side-effects.” Can anyone tell me why this is happening and possibly how to fix it?

please try to format all of your code.

this line

xpos == transform.position.x;

should probably read:

xpos = transform.position.x;

the error is because you’re trying to perform a comparison without an assignment for it’s result. something like

var xIsTheSame = (xpos == transform.position.x);

is perfectly valid…