How to check the same boolean in all child objects?

I have a box of items. Each item has a script with a boolean called isAtStartPos, which is true when the object’s transform.position is equal to its start position.

I have another script on the box which needs to know if all of these child objects are at their start positions but can’t seem to figure out how to achieve this through code. I have the below function, but it always returns true. How can I get it to return false?

public class Restock : MonoBehaviour
{

Transform[] children;
GameObject[] allChildren;
Transform randomObject;
public AudioSource audio;
public AudioClip pop;
public AudioClip kaching;
public GameObject Player;
public GameObject restockingGIF;
public GameObject crosshairs;
public GameObject radialProgress;
float resetTime;
int index;
bool isFinished;
bool allChildrenAtStart;
public float resetSpeed;
bool allChildrenReset;

// Start is called before the first frame update
void Start()
{
    children = gameObject.GetComponentsInChildren<Transform>();
    allChildren = new GameObject[transform.childCount];
    resetTime = 0.0f;
    allChildrenAtStart = true;
}

// Update is called once per frame
void Update()
{
    float dist = Vector3.Distance(Player.transform.position, transform.position);

    if(Input.GetKey(KeyCode.E) && (Time.time - resetTime) > resetSpeed && dist <= 4 && Player.GetComponent<PlayerMovement>().shotgunEquipped == false){
        ResetRandomObject();
        crosshairs.SetActive(false);
        restockingGIF.SetActive(true);
    }
    if(Input.GetKeyUp(KeyCode.E) && Player.GetComponent<PlayerMovement>().shotgunEquipped == false){
        crosshairs.SetActive(true);
        restockingGIF.SetActive(false);
    }

}

void ResetRandomObject(){
    int i = 0;
    foreach (Transform child in transform){
        allChildren *= child.gameObject;*

i += 1;
}
int index = Random.Range(0, allChildren.Length);
GameObject currentChild = allChildren[index];
if(currentChild.GetComponent().isAtStartPos == false){
StartCoroutine(currentChild.GetComponent().Reset());
audio.PlayOneShot(pop);
//finished = true;
resetTime = Time.time;
}
CheckIfAllReset();
}
IEnumerator Finished(){
audio.PlayOneShot(kaching);
yield return new WaitForSeconds(1);
isFinished = false;
}
bool CheckIfAllReset(){
for(int i = 0; i < allChildren.Length; i++){
if(allChildren*.GetComponent().isAtStartPos == false){*
Debug.Log(“not all children at start”);
return false;
}
}
Debug.Log(“all children at start”);
return true;
}
}

I would use little different way to loop.
But either way should be ok. The question is maybe how and where do you populate the allChildren?

bool CheckIfAllReset(){
         foreach(GameObject go in allChidren){
             if(!go.GetComponent<ResetObject>().isAtStartPos){
                 Debug.Log("not all children at start");
                 return false;
             }
         }
         Debug.Log("all children at start");
         return true;
     }

The loop is fine. Please show how you are setting the allChildren array to true…

Hi, I am pasting my own piece of code. I hope you can understand it.

public void CheckDone()
{
if (IsAllEggsPlaced()==true)
{
Debug.Log(“Finished”);
}

    if (IsAllEggsEmpty() == true)
    {
        Debug.Log("Empty Bro");
    }

}

private bool IsAllEggsPlaced()
{
    for (int i = 0; i < emptyPlaces.Length; ++i)
    {
        if (emptyPlaces*.GetComponent<CheckObjectFlag>().egg == false)*

{
return false;
}
}
return true;
}
private bool IsAllEggsEmpty()
{
for (int i = 0; i < emptyPlaces.Length; ++i)
{
if (emptyPlaces*.GetComponent().empty == false)*
{
return false;
}
}
return true;
}