I cant look sideways with this code.

I don’t get why I cant look sideways? I can look up and down fine though. the code:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class MouseLook : MonoBehaviour
{

public float mouseSensetivity = 100f;

public Transform playerbody;

float xRotation = 0f;

void Start()
{
    Cursor.lockState = CursorLockMode.Locked;
}

void Update()
{
    float mouseX = Input.GetAxis("Mouse X") * mouseSensetivity * Time.deltaTime;
    float mouseY = Input.GetAxis("Mouse Y") * mouseSensetivity * Time.deltaTime;

    xRotation -= mouseY;
    xRotation = Mathf.Clamp(xRotation, -90f, 90f);

    transform.localRotation = Quaternion.Euler(xRotation, 0f, 0f);
    playerbody.Rotate(Vector3.up * mouseX);

    
}

}

I’m not an expert in quaternions, so I may be totally wrong, but you could try using Euler angles instead. I have no idea if this will actually do anything, but you can read more here: Unity - Scripting API: Transform.eulerAngles

You’ve been applying your current-frame’s yaw (horizontal) rotation rather than the total value.

// This only applies your yaw for the current frame
playerbody.Rotate(Vector3.up * mouseX);

// You meant to use this:
playerbody.Rotate(Vector3.up * xRotation);

As an added note, however, Mouse input is provided and generally expected on a per-frame basis. You don’t need to multiply it by Time.deltaTime, since the framerate will inherently influence the value provided as input.