How to cap this movement?

I know what is causing this, but in the vector3 near the bottom, just doing CameraDistance.y and CameraDistance.z doesnt work.

using UnityEngine;
using System.Collections;

public class CameraController : MonoBehaviour {
	public float Sensitivity;
	public float MaxPos;
	public float MaxAngle;
	private float MouseY;
	private float MouseYSet;
	private float CameraAngle;

	private Vector3 CameraDistance;

	public GameObject CameraTarget;
	void Start () {
	void Update () {
		// Look controls
		MouseY -= Input.GetAxisRaw ("Mouse Y");
		CameraAngle = Mathf.Clamp (CameraAngle + (MouseY - MouseYSet) * Sensitivity * 10, -MaxAngle, MaxAngle);
		CameraDistance = new Vector3 (transform.localPosition.x, Mathf.Clamp (CameraDistance.y + (MouseY - MouseYSet) * Sensitivity * 10, CameraTarget.transform.localPosition.y + CameraTarget.transform.localScale.y / 2, CameraTarget.transform.localPosition.y + CameraTarget.transform.localScale.y / 2 + MaxPos), Mathf.Clamp (CameraDistance.z + (MouseY - MouseYSet) * Sensitivity * 10, CameraTarget.transform.localPosition.z - MaxPos, CameraTarget.transform.localPosition.z));
		if (MouseY != 0)
			transform.localRotation = Quaternion.Euler (CameraAngle, transform.localRotation.y, transform.localRotation.z);
			transform.localPosition = new Vector3 (transform.localPosition.x, transform.localPosition.y + CameraDistance.y, transform.localPosition.z + CameraDistance.z);
			MouseYSet = MouseY;

Though this is not directly related to the current problem you are asking about, you really need to learn from previous mistakes, the line:

transform.localRotation = Quaternion.Euler (CameraAngle, transform.localRotation.y, transform.localRotation.z);

is not going to work for the exact reason and answer you were given in this question previously. It honestly makes me ~personally~ far less willing to help if you don’t actually learn from answers given.

But perhaps it was a genuine mistake, in which case you should refer to that answer linked!