Help: Camera script sets Camera rotation always to World Rotation

I have a big Problem with my Mouse Look script.

I have set the PlayerController to rotate with the camera and the camera to follow the PlayerController.
They have the same Parent.

Now if I start the game and the Parent is turned around the y axis 270° the camera turns itself back to the world rotation and in the camera transform tab its then set to 90°…
if I rotate the camera in the transform tab it goes back to the world rotation too…

I found the part in my code which causes this problem but I dont know how to fix it…
I mark the part in my code.

please help.

var playerBody : GameObject;
var cameraOffset = 0.7;

var lookSensitivity : float = 4;
@HideInInspector
var yRotation : float;
@HideInInspector
var xRotation : float;
@HideInInspector
var currentYRotation : float;
@HideInInspector
var currentXRotation : float;
@HideInInspector
var yRotationV : float;
@HideInInspector
var xRotationV : float;

var lookSmoothDamp : float = 0.08;
@HideInInspector
var currentAimRacio : float = 1;

private var headbobbing : Headbobbing_harry;

function Awake()
{
	playerBody = GameObject.Find("Player Body");
	headbobbing = GetComponent(Headbobbing_harry);
}
     
function LateUpdate()
{
	yRotation += Input.GetAxis("Mouse X") * lookSensitivity * currentAimRacio;
	xRotation -= Input.GetAxis("Mouse Y") * lookSensitivity * currentAimRacio;

	xRotation = Mathf.Clamp(xRotation, -90, 90);
	
	currentYRotation = Mathf.SmoothDamp(currentYRotation, yRotation, yRotationV, lookSmoothDamp);
	currentXRotation = Mathf.SmoothDamp(currentXRotation, xRotation, xRotationV, lookSmoothDamp);


// this line sets the start rotation always to the world rotation....
	transform.rotation = Quaternion.Euler(currentXRotation, currentYRotation , 0);


	transform.position = playerBody.transform.position + Vector3(0,cameraOffset,0);
}

I solved the problem!
I am new to coding and so I did not understand why the transform.rotation.y here not worked.
now I know it better.
I tryed now transform.rotation.eulerAngles.y and it works.
here is the code that I put into the function Awake to get it to work.

function Awake()
{
	playerAll = GameObject.Find("Player All");
	playerAllRot = playerAll.transform.rotation.eulerAngles.y;
	yRotation = playerAllRot;
	currentYRotation = playerAllRot;
}