why we used rotate for mouse x and and why we used localrotation for mouse y ?,

float mouseX = Input.GetAxis(“Mouse X”) * Time.deltaTime * mouseSensitivity;
float mouseY = Input.GetAxis(“Mouse Y”) * Time.deltaTime * mouseSensitivity;

    xRotation -= mouseY;
    xRotation = Mathf.Clamp(xRotation, -90f, 90f);
    
    transform.localRotation = Quaternion.Euler(xRotation, 0f, 0f);
    playerbody.Rotate(Vector3.up * mouseX);

,

Because the y rotation should wraparound freely as you can rotate 360°. So you use the “mouseX” delta value to rotate the player relative depending on how far the mouse was moved left / right.

This script is most likely attached to the camera which is a child of the player. The up-down rotation of the camera should be an absolute rotation in order to clamp the rotation. That’s why the script uses a seperate variable (xRotation) to keep track of the x rotation. You could use a similar approach for the y rotation, but that’s not really necessary as you usually don’t want to restrict your y rotation