How to limit the rotation of my third person camera?

So, I’m making a script that controls my third person camera over-the-shoulder style. It kinda works similar to what I want, but it have a minor inconvenient: when I rotate too fast or for a long period in the Y axis, the camera loses the player from the view, unless I stop moving the player, which is when the camera returns to its place.

This is my code so far:

[SerializeField]
    private Transform target;

    private void LateUpdate()
    {
        transform.position = target.position;
        transform.rotation = Quaternion.RotateTowards(transform.rotation, target.rotation, Time.deltaTime * 120f);
    }

How do I limit the rotation of my camera? I found a lot of solutions here and the forum, but most of them are mouse look oriented, and the other solutions didn’t work.

Hello! I’m pretty new to Unity but I hope this helps!
So basically you need to create a public float called clampAngle and set it to whatever you want.
Then add transform.rotation.x = Mathf.Clamp (transfrom.rotation.x, -clampAngle, clampAngle);
I have it on the x axis, but it should work on any of them. Also, if this doesn’t work still then I think I know why, and I can still help. Hopefully it does though!