Accessing a variable from other script

Hi. I’m following a tutorial to make a multiplayer network, but im getting an error when i try to access a variable from other script.

This is the line where i got the error:

MultiplayerManager.instance.PlayerName = GUI.TextField(new Rect(350,10,200,30), MultiplayerManager.instance.playerName);

It says: Type MultiplayerManager' does not contain a definition for playerName’ and no extension method playerName' of type MultiplayerManager’ could be found (are you missing a using directive or an assembly reference?)

The MultiplayerManager script has a public string called PlayerName and i have void Start in it with instance = this.

Thanks.

if you instance the object MultiplayerManger

MultiplayerManger thisManger = new MultiplayerManger();

you must acces the variable with thisManger.playerName.

If that is what you ment.

From your question, it seems that you’ve declared PlayerName but is trying to access playerName - they are different things, since Unity is case sensitive.