How to freeze the z axis while rotating

I’m trying to make a third person camera but when rotating the z axis it makes it look weird and i don’t know how to make it not rotate the z axis here’s my code
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CameraController : MonoBehaviour
{

    private GameObject player;
    private GameObject cam;

    public float senstivity;
    public float smoothing;

    // Use this for initialization
    void Start()
    {
        cam = GameObject.FindGameObjectWithTag("MainCamera");
        player = GameObject.FindGameObjectWithTag("Player");
    }

    // Update is called once per frame
    void Update()
    {
        if (player == null) return;
        transform.position = new Vector3(player.transform.position.x, player.transform.position.y + 4, player.transform.position.z);

        var mouse = new Vector2(Input.GetAxisRaw("Mouse X"), Input.GetAxisRaw("Mouse Y"));
        var v = new Vector3(-mouse.y, mouse.x, 0) * senstivity * (1 / smoothing);
        transform.localRotation *= Quaternion.Euler(v.x, v.y, 0);
    }
}

the camera is a child of an gameobject called camera controller which stays on top of the player
(because i want the camera to rotate around a point on top of the player)

Actually as much as I understood reading your question @HamzaNa113, I am not sure you want to freeze the Z axis rotation of the player Camera or a player or a rigidbody.
Well, if its a rigid body, you can check the freeze rotation under constraints in the rigid body menu in the inspector.113658-capture.jpg

And I dont know for sure, but you can experiment by applying rigidbody to the camera and enabling the suitable constraints.
I hope my answer helped you.

Try changing the order of the variables you’re putting into Quaternion.Euler(), that should do it.