Question regarding this line of code

This line of code is in a book, but it dosen't work

transform.position.x += .2;

In the book all it is is a

void Update() {
   transform.position.x += .2; 
}

This should move the current object +.2 each update for x. Thanks

Also the error is "Assets/Paddle.cs(16,19): error CS1612: Cannot modify the return value of `UnityEngine.Transform.position' because it is not a variable" which i undersatnd that transform.position.x returns a value and cannot be set. But this book says it and it's a unity game dev book.

In UnityScript (~JavaScript), that code should work fine. In C#, however, you have to assign a new Vector3 to the position.

transform.position = transform.position + new Vector3 (.2f, 0, 0);

Alternatively, you can use Transform.Translate to translate the position by the specified amount. i.e.

transform.Translate(0.2f, 0, 0);