Locking player script when menu is toggled?

Here I have a basic menu script which toggles my menu via “tab”. I want to disable the player controller script I have (Named PlayerController) so that I dont continue to move around and play while the menu is up. I tried to do this via accessing the script PlayerController and setting it as “lockkeys”, then using lockkeys to disable and enable it under the “tab” press functionality. It doesn’t seem to work. Is there a better way to do this, or am I doing something wrong?

public class openmenu : MonoBehaviour {

	public PlayerController lockkeys;
	public Canvas IngameOption;
	private bool menuEnabled = false; // call this whatever you wan

	// Use this for initialization
	void Start ()
	{
		IngameOption = IngameOption.GetComponent<Canvas>();
		menuEnabled = false;
		IngameOption.enabled = menuEnabled;
		lockkeys = GetComponent<PlayerController> ();
	}

	// Update is called once per frame
	void Update ()
	{
		if (Input.GetKeyDown("tab"))
		{
			menuEnabled = !menuEnabled;
			IngameOption.enabled = menuEnabled;
			lockkeys.enabled = !lockkeys.enabled;
		}
}
}

Just a idea, have you tryed using multithreading? Locking part of a script, until a value is returned. That way, the locked code cant be accessed by any other simultanious object running. You can adapt it to your situation as you seen fit better.

Hope it helps somehow. Iam not at home to give you a few examples of its awesome uses.