how to make Camera not leave world border

im making a 2½d sidescroller and i have a camera that follows the player around on the X axis but i just cant figure out how to make the camera not leave the world border no matter what i do it just dosent work and what i mean by leaveing the world border is that i have 1 wall in each end of the map and once the camera hits, sees the wall it needs to stop following the player in that direction this is what i have working

	public Transform playerToFollow;
	public float Height;
	public float Zoom;

	void Start () {
	
	}

	void Update () {

			transform.position = new Vector3 (playerToFollow.position.x, Height, Zoom);
	}

this pretty much just follows the player in the x axis

You might be looking for the Mathf.Clamp function. Just clamp the Vector3 to the boundaries of your world and all should be fine.

transform.position = new Vector3 (Mathf.Clamp(playerToFollow.position.x, leftLimit, rightLimit), Height, Zoom);

okay after posting this i saw alot of related questiona and found my answer this is what i did

	public Transform playerToFollow;
	public float Height;
	public float Zoom;
	public float max;
	public float min;

	void Start () {
	
	}

	void Update () {
		if (playerToFollow.position.x>min && playerToFollow.position.x<max)
		{
			transform.position = new Vector3 (playerToFollow.position.x, Height, Zoom);				
		}
	}

i check for the players position instead of the camera it works really well