child count wants to change from bool?

So I have a GO whoose children I want to delete but if I try to do it with the following code I get an error at “i = child.transform.childCount” saying it can’t convert from BOOL to int. I have no idea where it’s geting a bool.

GameObject child = GameObject.FindGameObjectWithTag(“PickUpController”);
for (int i = 0; i = child.transform.childCount; i++)
{
child.transform.GetChild(i).GetComponentInChildren().destroy = true;
}

I have spent hours trying to fix this and after a lot of experimentation I found only this working:

GameObject child = GameObject.FindGameObjectWithTag(“PickUpController”);
int i = 0;
while (child.transform.childCount != 0)
{
child.transform.GetChild(i).GetComponentInChildren().destroy = true;
i++;
}

Thanks for the help

i = child.transform.childCount

That part of the if statement expects a boolean result to determine when to stop executing the loop. You have an assignment statement there - you’re assigning child.transform.childCount to i. What you probably want is i < child.transform.childCount, which does a comparison, returning true until i reaches childCount.