Prevent Z rotation on 3rd person camera

I’m relatively new to unity and have been trying to make a 3rd person camera work with mouse movements. So far I have it working sort of but currently I’m getting rotation on the z axis as well despite never telling the z axis to rotate. I’m aware that this is because of the way axis rotate however I have no idea how to solve the solution. My current code is as follows:

//Mouse Look
float rotx = Input.GetAxis("Mouse X") * lookSpeed * Time.deltaTime;
float roty = Input.GetAxis("Mouse Y") * lookSpeed * Time.deltaTime;

playerTransform.RotateAround(playerPos, Vector3.up, rotx);
camTransform.RotateAround(playerPos, Vector3.right, -roty);

I know that you can solve this problem when using normal rotate by using but I have no idea how to solve this with rotate around.

Try this:

    float lookSpeed=3f;
	float rotx=0;
	float roty=0;

    void Update () {

	rotx += lookSpeed * Input.GetAxis ("Mouse X");
	roty -= lookSpeed * Input.GetAxis ("Mouse Y");

	camTransform.eulerAngles = new Vector3 (roty, playerTransform.eulerAngles.y, 0.0f);
	playerTransform.eulerAngles = new Vector3 (playerTransform.eulerAngles.x, rotx, 0.0f);