Changing a variable value

I get error NullReferenceException: Object reference not set to an instance of an object
SquareScript.Update () (at Assets/Scripts/SquareScript.cs:21)
when using these two scripts. Im trying to set the variable OsTurn to the value of IsOsTurn.

using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    
    public class SquareScript : MonoBehaviour {
    	[SerializeField]
    	//Identifies whether the square was clicked (tapped).
    	private bool IsClicked = false;
    	//Identifies whose turn it is.
    	private bool OsTurn;
    	//Identifies whether to check for click.
    	private bool CanBeClicked = true;
    	//Game object references
    	public GameObject x;
    	public GameObject o;
    	public ManagerScript _ManagerScript;
    	void Start () {
    		
    	}
    	void Update () {
    		 OsTurn = _ManagerScript.IsOsTurn;
    			if (Input.touchCount == 1)
    			{
    				Vector3 wp = Camera.main.ScreenToWorldPoint(Input.GetTouch(0).position);
    				Vector2 touchPos = new Vector2(wp.x, wp.y);
    				if (GetComponent<Collider2D>() == Physics2D.OverlapPoint(touchPos)){
    					if (CanBeClicked) {
    					Debug.Log ("touched" + gameObject.name);
    					if (OsTurn) {
    						Debug.Log ("Player One has put a piece on spot " + gameObject.name);
    					} else {
    						Debug.Log ("player Two has put a piece on spot " + gameObject.name);
    					}
    
    					changeTurns ();
    					}
    				}
    
    			}
    		}
    	void changeTurns () {
    		_ManagerScript.IsOsTurn = !_ManagerScript.IsOsTurn;
    	}
    
    }

Second script

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

public class ManagerScript : MonoBehaviour {
	public bool IsOsTurn = true;
	// Use this for initialization
	void Start () {

	}

	// Update is called once per frame
	void Update () {

	}
}

Hi there.

Based on the error you gave, and looking at what boolean you are trying to assign from _managerScript.IsOsTurn, one can only assume _managerScript is null.

Seeing as it is not being assigned in code, did you mean to assign this in the inspector, or did you simply forget to give it an object in the class?

Hope this helps!

@Matthewj866 That was supossed to be assigned in Void Start Thanks! Ill see if that works.