UnityException: Transform child out of bounds.

I’m getting the error in the title from this line:

 = Instantiate(droneConstruct,spawnpointStack.GetChild(spc).position,Quaternion.LookRotation(transform.position));

**EDIT** So I fixed the problem, but now I'm getting this:

"NullReferenceException: Object reference not set to an instance of an object"

Why, Unity! Why!

As a general rule of thumb, a NullReferenceException always means you are attempting to access a member of an object, be it class field or method, the reference to which is null. This typically occurs because an attempt to acquire a reference failed, such as through the use of GetComponent where a scriptname is spelled wrong, the gameobject doesn’t have that component attached at all, or perhaps a call to GameObject.Find where the wanted gameobject’s name is invalid.

It’s hard to know just what’s wrong in your case because you only posted one line of code, naturally. But if I were to venture a quick guess, anyway, I’d bet it’s probably spawnpointStack being null. Check the state of that object before the line you posted by simply shooting the variable into a call to Debug.Log. Does that print “null” to the console?

If not, it is likely the prefab you’re trying to instantiate a copy of, that is, the object called “droneConstruct”. Is this a public variable in your script which is supposed to reference a prefab in your project? If so, have you remembered to drag the prefab onto that variable in the editor?