How can the first C# script get the second C# script data?

public class First : MonoBehaviour {

public GameObject secondClass;

public Vector3 pos;

void Update () {

if (Input.GetKey(KeyCode.Space) )
{
Instantiate(secondClass, pos, Quaternion.identity);

        Debug.Log(secondClass.GetComponent<Second>().open);   //this will print false,WHY?

//Is the “Instantiate” problem?
}
}
}

public class Second : MonoBehaviour {

public bool open;

void Start (){ open = false; }

void Update (){

int a = 1;

if(a == 1)
{
open = true;

Debug.Log(open); //this will print true
}

The reason why you don’t see the value as true is because Start and Update methods will only be called on the next frame, after Instantiate is called.
Therefore you must either wait for the next frame to check the value, or put the Start/Update on a public method of Second class which is called before you read “open”.

Please be aware calling Start/Update before the object is properly initialized by the UI system will cause all sorts of inconsistencies when reading the objects Mono values.