Script makes my unity Crash

I am new to unity and don’t know if this script is good, it’s bits and bobs of other scripts it give me no errors though but every time I press play my unity crashes. I am hoping someone could tell me why that is or hint to a reason why it might be and btw I know this code is terrble but I am just a beginner.

using UnityEngine;
using System.Collections;

public class terrainGenerator : MonoBehaviour {

    //Raycast
    bool foundhit = false;
    RaycastHit hit = new RaycastHit();
    public Transform cube;
    public float raycastDist = 10;
    public string tagCheck = "Edge";
    public bool checkAllTags = false;

    //block placement
    public bool running = false;
    public float speed = 4;
    Ray ray;
    
    
    //spawning
    public GameObject[] obj;
    public float spawnMin = 1;
    public float spawnMax = 2;
	
    // Use this for initialization
	void Awake ()
    {
        spawn();
        running = true;
        while (running == true)
           

           if(Physics.Raycast(transform.position, transform.forward, raycastDist))
           {
               foundhit = true;
           }
           if(foundhit == true)
           {
               if(Physics.Raycast(transform.position, transform.forward, raycastDist))
               {
                   
               }
           }
       }


    void spawn()
    {
        Instantiate(obj[Random.Range(0, obj.GetLength(0))], transform.position, Quaternion.identity);
        Invoke("spawn", Random.Range(spawnMin, spawnMax));
    } 
}

running = true;
while (running == true)

That thar is what’s called an infinite loop… running is always true, so the game execution will never continue.

Pretty sure you shouldn’t start a while loop in Awake, even more sure there appears to be no way that while loop can exit.

You don’t need a while loop anyway, move the following lines to Update:

	void Update () {
	
		if(Physics.Raycast(transform.position, transform.forward, raycastDist))
		{
			foundhit = true;
			Debug.Log ("FoundHit = " + foundhit);
            foundhit = false; // just to reset so we only get a debug if hit in that frame
		}
	}

Be very, very, very careful with while loops, if possible avoid at all costs.