Unity fails when i press play

hi, i’ve been having this problem for a few days now and it’s really anoying. i’m making this simple game and for now in the scene there are: a plane, a cube that spawns some spheres, a tower that does the same thing. the problem is: if i press play when all this stuff is in the scene, unity won’t work: it completley freezes. instead if i press play when i put in the scene only the plane, and the cube that moves around with the arrow keys and that spawns spheres, it works perfectly fine. could this be a problem caused by my (very, very basic) scripts, even though it doesn’t show any kind of error? thank you for your response

You can use loops. But they need to not block the main execution thread. So infinite loops in coroutines (with yields) are ok. I suspect what you meant to do was this:

     using UnityEngine;
     using System.Collections;
     
     public class Tower : MonoBehaviour {
         
         public GameObject towerBullet;
         public Transform towerBulletSpawn;
         [Range(1,5)]
         public float waitTime;
         
         private bool corutine = true;
         
         // Use this for initialization
         void Start () {
             StartCoroutine(Shoot());
         }
         
         // Update is called once per frame
         void Update () {
             
         }
         
         IEnumerator Shoot ()
         {
           while(true) {
             Instantiate(towerBullet, towerBulletSpawn.position, Quaternion.identity);
             yield return new WaitForSeconds(waitTime);
           }
         }
         
     }