How Can I Lock The Cursor Position?

Hello, I am working on an FPS game and cannot get the Cursor.lockState code to work. Yes, I have read the documentation page, but I have not been able to remove the GUI elements the script has. I have not been able to successfully recreate or modify the code, and I do not feel the documentation gave enough information for me to accurately understand the true workings. If anyone can help me, it would be greatly appreciated!

Have you tried with only these two lines and nothing else?

private void Awake ()
{
	Cursor.lockState = CursorLockMode.Locked;
	Cursor.visible = false;
}