Saving Player Position using player prefs?

C# ONLY PLEASE
I am using player prefs to save my players position but I am getting these errors:

Assets/PosSave.cs(16,42): error CS1612: Cannot modify a value type return value of `UnityEngine.Transform.position’. Consider storing the value in a temporary variable

Assets/PosSave.cs(17,42): error CS1612: Cannot modify a value type return value of `UnityEngine.Transform.position’. Consider storing the value in a temporary variable

Assets/PosSave.cs(18,42): error CS1612: Cannot modify a value type return value of `UnityEngine.Transform.position’. Consider storing the value in a temporary variable

I
do not know how to fix these

Here is my script

using UnityEngine;
using System.Collections;

public class PosSave : MonoBehaviour {
	public GameObject player;
	public float x;
	public float y;
	public float z;
	// Use this for initialization
	void Start () {
		if (PlayerPrefs.HasKey ("x") && PlayerPrefs.HasKey ("y") && PlayerPrefs.HasKey ("z")) {

			x = PlayerPrefs.GetFloat("x");
			y = PlayerPrefs.GetFloat("y");
			z = PlayerPrefs.GetFloat("z");
			player.transform.position.x = x;
			player.transform.position.y = y;
			player.transform.position.z = z;

		}
	
	
	}
	
	// Update is called once per frame
	void Update () {
		x = player.transform.position.x;
		PlayerPrefs.SetFloat("x", x);
		y = player.transform.position.y;
		PlayerPrefs.SetFloat("y", y);
		z = player.transform.position.z;
		PlayerPrefs.SetFloat("z", z);
		
		
	}
}

You can’t do this…

player.transform.position.x = x;

You can’t modify an individual component of a Vector3 variable in this manner.

To help you understand your error “Assets/PosSave.cs(17,42): error CS1612: Cannot modify a value type return value of UnityEngine.Transform.position’. Consider storing the value in a temporary variable”

Each step of this bit of code “player.transform.position.x” is a separate statement that returns something…

player returns a reference to the player,
transform returns a reference to the player’s transform,
position returns the value (a copy) of the Vector3
x returns the value (a copy) of the x element of the Vector3

If you try to modify the copy, you’re just changing the value you have been returned… not the value that’s stored in transform. That’s why it’s telling you to make a temporary variable first… because you CAN replace the value stored in position with the same value type.

You just have to make a Vector3 first… and then assign it to transform.position.

x = PlayerPrefs.GetFloat("x");
y = PlayerPrefs.GetFloat("y");
z = PlayerPrefs.GetFloat("z");
Vector3 posVec = new Vector3(x,y,z);
player.transform.position = posVec;

Also, and this is a separate issue…

Writing to player prefs every frame is very inefficient and not at all advisable.