Cursor.lockState = CursorLockMode.Locked; isn't working in full screen

Hello, would anyone know how to solve my problem? I’m using Cursor.lockState = CursorLockMode.Locked; to lock the mouse, but for some reason, when I put the game in full screen, this command isn’t working. Would anyone know how to fix it?

Unity version: 2022.3.20f1