Follow Camera

I have follow camera script. It’s working, but when I change coordinate z the camera wont follow the player. Here’s my script. Can you guys help me please. Thank you.

public Camera mainCamera;

void Start () {
	mainCamera = GameObject.FindGameObjectWithTag ("MainCamera").camera;

void LateUpdate () {
	Camera.main.transform.position = new Vector3
		(transform.position.x, 10, transform.position.z);

Once see this technique.

public Transform CharacterToFollow;
public Transform Cam;
int Distance = 1; // Whatever

void Update()
   Cam.transform.position = new Vector3(Cam.transform.position.x,Cam.transform.position.y,CharacterToFollow.transform.position.z - Distance);