Unity Arbitrarily Freezes When Running Scripts

I have this simple little script right here:

using UnityEngine;
using System.Collections;

public class Build : MonoBehaviour {

	// Use this for initialization
	public GameObject brick;
    //public int length = 10;
    //public int width = 10;

    void Start()
    {
        for (int y = 0; y < 2; y++)
        {
            for (int x = 0; x < 2; x++)
            {
                Instantiate(brick, new Vector3(x, 0, y), Quaternion.identity);
            }
        }
    }

	
	// Update is called once per frame
	void Update () {
	
	}
}

That’s all my project does for now, but it freezes every time that I try to play it. Coming from a C++ background, I’m not seeing how a simple nested loop is causing Unity to die on me, unless there’s something specific with the C# language that I’m missing, or something technical with unity, because this is pretty much copied straight from the Unity Documentation.

You don’t have this script attached to your brick prefab do you? A common infinite loop is to have an object Instantiate itself during start.

Uh… not sure where the answer went. Anyways, BoredMormon pointed out that I had the script attached to the brick prefab itself, rather than solely the starting point. So to make the floor it set down a brick, which made it’s own floor, which set down a brick, which made it’s own floor, etc.

So if anyone else has a similar problem, make sure that your scripts are set to the right object. So credit to BoredMormon.