error CS0021: Cannot apply indexing with [] to an expression of type 'GameObject'

Help please

public class ObjectPooler : MonoBehaviour
{
public GameObject pooledObject;

public int pooledAmount;

List<GameObject> pooledObjects;
    // Start is called before the first frame update
    void Start()
    {
       pooledObjects = new List<GameObject>();
       for(int i = 0; i < pooledAmount; i++)
       {
              GameObject obj = (GameObject)Instantiate(pooledObject);
           obj.SetActive (false);
           pooledObjects.Add (obj);
       }
    }

public GameObject GetPooledObject()
{
   for(int i = 0; i < pooledObjects.Count; i++)
   {
          if(!pooledObjects[i].activeInHierarchy)
       {
              return pooledObject[i];
       }
   }
    GameObject obj = (GameObject)Instantiate (pooledObject);
    obj.SetActive (false);
    pooledObjects.Add (obj);
    return obj;
}
}

I guess the error is in line 26 (you really should tell us). You are missing an ‘s’ in pooledObjects[ ]

That’s why I avoid giving variables names that are so easy to mix up.

Oh, my bad. Thanks man :smile: