NullReferenceException when getting value from different script

Hi guys, I have an issue with NullReferenceException, I just can’t figure it out. I have 2 scripts on different objects, WorldOrder and SpawnGround. SpawnGround is supposed to get the world order from WorldOrder and then spawn the ground around the player. Here’s SpawnGround, the error line is in OnTriggerEnter2D and marked with a comment:

public class SpawnGroundFront : MonoBehaviour {
	public GameObject player;

	int groundIndex;
	int loadDist;
	List<string> worldOrder;

	void Start(){
		player = GameObject.FindWithTag("Player");
		try{
			loadDist = player.GetComponent<WorldOrder>().loadDist;
			groundIndex = player.GetComponent<WorldOrder>().groundIndex;
			worldOrder = player.GetComponent<WorldOrder>().worldOrder;
		}
		catch(NullReferenceException ex){
			Debug.Log("Player not found!");
		}
	}

	void OnTriggerEnter2D(Collider2D other){
		if(player != null){
			if(other.gameObject == player){
				//get the stack of world names
				float vel = other.GetComponent<Rigidbody2D>().velocity.x;

				//player is moving forward
				if(vel > 0){
					//there is no ground data to load
					if(worldOrder[groundIndex + loadDist + 1] == null){ //THIS LINE GIVES THE ERROR
						SpawnForwardNew();
						PushBackwardStack();
						//groundIndex++;
					}
					//there is some ground data to load
					else{
						SpawnForwardLoad();
					}
				}
				else if(vel < 0){
					PushForwardStack();
				}
			}
		}
		else{
			Debug.Log("No player object!");
		}
	}

Here is WorldOrder:

public class WorldOrder : MonoBehaviour {

	//other methods treat this as a stack where push adds a value to the front or back, same with pop
	public List<string> worldOrder;

	public GameObject[] groundObj;
	//public GameObject[] platformObj;

	public int loadDist = 2;
	public int groundIndex;

	void Awake(){
		if(GameObject.FindWithTag("Ground") == null){
			SpawnInitial();
			groundIndex = loadDist;
		}
	}

	void GetWorldOrder(){
		GameObject curr = GameObject.FindWithTag("Ground");
	}

Seems like you never assign a value to worldOrder in the WorldOrder class, so it’s null. Then you try to acess one of it’s members.

Try changing the line to

public List<string> worldOrder = new List<string>();

The only other thing I can think about is that OnTriggerEnter2D is called before Start(), though I can’t think of why this happens. You can check this by adding logs in each method and see which one is called first.

The object that holds WorldOrder is a child of my player so I should have used GetComponentInChildren instead of GetComponent.