Object reference not set to an instance of an object error

Trying to access array within another script, have tried the below but getting the error. Seems what im trying to do is pretty basic but just cant work it out :frowning:

Class One (Startup)

public float[] theArray;
theArray = .....

Class Two

float[] theArray;

Startup startup = startup.GetComponent<Startup>();
theArray = startup.theArray;

Error

Object reference not set to an instance of an object

This is your problem

 Startup startup = startup.GetComponent<Startup>();

You are trying to use the null startup variable to get a copy of a Startup component.

You need to work out what the Startup component is attached to - if it is the same game object then:

  Startup startup = GetComponent<Startup>();

If it’s on another game object then you need to get a reference to that game object and:

  Startup startup = theOtherGameObjectOrComponent.GetComponent<Startup>();

Check out the GetComponent tutorials on Unity Gems or the basic instructions here