Main Camera disappears when testing

I’ve had this problem for two days now, and I can’t figure out why it’s doing it. First I’m using Android build setting with an onscreen jump button.

When I run the game and test it after a random amount of time the main camera disappears and the game goes to my game over screen. I know the camera disappears because if I hit the pause button and see what’s going on the main camera and all it’s child objects are gone.

I also get an error code now on one of my scripts, this script has been working the last 2 weeks and now it throws this alarm. The alarm is: NullReferenceException: Object reference not set to an instance of an object
CoinScript.OnTriggerEnter2D (UnityEngine.Collider2D other) (at Assets/Scripts/CoinScript.cs:14)

Here is the script

using UnityEngine;
using System.Collections;

public class CoinScript : MonoBehaviour {

	HUDScript hud;
	
	void OnTriggerEnter2D(Collider2D other)
	{
		
		
		if (other.tag == "Player") {
			
			hud = GameObject.Find ("MainCamera") .GetComponent<HUDScript>();
			hud.IncreaseCoins(1);
			Destroy (this.gameObject);
		}
	}
}

I have checked and the script is on the object and the one this script is looking for is on the Main Camera.
Thanks for any help you can give me.

Edit: Okay, I’m pretty sure I’m getting the error code because the MainCamera disappears, because when I change the script to the player I don’t get it.

Edit 2: Pretty sure it’s not the camera follow script either, just wrote another one, and it does the same thing. I’m at a loss here.

OK, I’ve changed camera scripts, got rid of the child gameobjects and rewritten my spawn scripts differently and the game still crashes when I play it. Not sure what is going on, anyone have any ideas?

I figured it out, it was from one of my collision objects spawned, they sometimes touched the ground and the destroy script on them destroyed everything on the screen. I just made it a script for them to just kill the player.