CursorLockMode.Locked doesnt work

This is my start function

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

it is on an active script but the cursor is not hidden nor is it locked to the centre of the screen when I play.

I’m am using Unity 2020.2.3f1

any help is appreciated

Try making a build, and see if that fixes the problem. If that doesn’t fix the problem, try:

Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = false;