My for cycle works first time, but not the second

 byte i = 0, j = 0;

        do
        {
            j = (byte)Random.Range(0, 52);

            if (isObjectPresent[j]) //bool array, it checks if the object is present in the "deck"
            {
                isObjectPresent[j] = false;

                objectsOnField[i] = princDeck[j]; //set the clone of the prefab
                 
                objectsOnField[i] = Instantiate(objectsOnField[i], fieldPositions[i], Quaternion.identity);

                i++; //i increases only if this IF is true
            }

        } while (i < 6);

So, the first time i run this cycle, it works fine. The second instead, i don’t know why “i” doesn’t increase despite the “IF” block being executed, and the consequence is that the rest of the objects in the deck are instantiated and unity freezes. Where is the error?

I dont see a mistake. How did you determine what ‘i’ does not get incremented but the if was true? Unless it throws an exception inbetween, there should be no way for that to happen.