I created an object in a script and I’m trying to access that object from another script.
How can I do that? I tried myScriptRef.character.Health but it doesn’t work.

public class Character {
         public int Health = 100;
}


public class MyScript : MonoBehaviour {

     void Start() {
            Character character = new Character();
     }

}

public class MyOtherScript : MonoBehaviour {

     public MyScript myScriptRef;

     void Start() {
            Debug.Log(myScriptRef.character.Health); // Doesn't work
     }

}

you’re calling myScriptRef.CHARACTER.Health, it should be myScriptRef.myCharacter and the Character variable in “MyScript” should be public.

Also, establish the “Character myCharacter” class outside of the start function, not inside.