Changing Variables on one script with multiple other scripts

I am trying to set up the switch to determine who’s turn it is for a 2d-TBS game.

there is a script called BoardManager which constructs the board, and holds the following variables which determines who’s turn it is and how many actions they got

PlayerTurn
EnemyTurn
PlayerActions
EnemyActions

The Player script and the Enemy script had to be added to the “headquaters” Gameobject in order to make them function

each of them has a Boardmanager script added to it as well to make GetComponent() work

the problem im having is when one script is finished it’s turn, it’s supposed to set it’s turn to false with
boardmanager. X Player Turn = false; and then set the other script to true with
boardmanager. X OtherPlayer turn true;

but through debugging i have realized that both the boardmanagers attached to each headquarters are independant from each other, but i can’t remove them or else GetComponent() doesn’t work,

I need a way to reference only one Boardmanager, and get rid of the BoardManagers on the Headquarters, any ideas?

This would be a good time to use a singleton class. That way the player and the enemy could both look at the same BoardManager.

The quick and dirty way to do that is to add a new variable to your BoardManager script, like this:

public static BoardManager instance;

void Awake(){
 instance = this; // when the script starts, the instance variable gets set to this instance of the script.  Because it is static, there will be only one
}

then in your player and enemy code, to get the BoardManager you just say
var manager = BoardManager.instance;

then they will be referring to the same one.

As I said, that is quick and dirty. IF you want to make it fancier, do a search for Singleton on here and I’m sure there will be other examples.