How do I make the camera follow the player only on Y axis?

The camera follows player perfectely fine, but I don’t know how to make it move only on Y axis. (code taken from a tutorial video from youtube). Can you help me modify the code so it works as I want it to work?

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CameraFollow : MonoBehaviour
{
public float FollowSpeed = 2f;
public float yOffset = 1f;
public Transform target;

// Update is called once per frame
void Update()
{
    Vector3 newPos = new Vector3(target.position.x, target.position.y + yOffset, -10f);
    transform.position = Vector3.Slerp(transform.position, newPos, FollowSpeed * Time.deltaTime);
}

}

you set newPos = new Vector3(target.position.x, target.position.y + yOffset, -10f);
→ It will set posZ = -10f, follow target and change your posX and posY of your camera
if you want to move just only on Y axis, don’t change X and Z by this:
newPos = new Vector3(transform.position.x, target.position.y + yOffset, transform.position.z);