Help conlicting code kinda

Hi i am trying to get the camera to rotate around the player while the camera following the player but not on the
rotation but when the code to follow the character and the code to rotate around the player it stops working.

var target : Transform;
var speed : float = 5;
var zdistance : float;
var ydistance : float;
var xdistance : float;


function Update(){
 

    
    transform.LookAt(target);
    transform.position.z = target.position.z -zdistance;
    transform.position.y = target.position.y -ydistance;
    transform.position.x = target.position.x -xdistance;
    transform.RotateAround(target.position, Vector3.up, Input.GetAxis("Mouse X")*speed);
       
    }

Thanks

What are your values for zdistance, ydistance and xdistance?

Setting the individual components of transform.position doesn’t work because you’ll be changing the copy of the position vector, not the position vector itself. So instead of this:

    transform.position.z = target.position.z -zdistance;
    transform.position.y = target.position.y -ydistance;
    transform.position.x = target.position.x -xdistance;

Try this:

    var z =  target.position.z -zdistance;
    var y = target.position.y -ydistance;
    var x = target.position.x -xdistance;
    transform.position = new Vector3(x, y, z);

No still doesnt work it still prevents from me from rotating around the character

they are there so i can control where the camera is, without them the camera will be really close to the player on play mode and there so i can position the camera