How instantiate in array consecutive

Transform meatballSlots;
GameObject meatball;

    private void Update()
    {
        foreach (Transform meatballSlot in meatballSlots)
        {
            if (Input.GetKeyDown(KeyCode.Space))
            {
                Instantiate(meatball, meatballSlot);
            }
        }
    }

how can i to instantiate the “meatball” as child of “meatballSlot” consecutive, right now if i press space the “meatball” will instantiate on every “meatbalSlot”, but i need instantiate will consecutive from 0, 1, 2, 3 and then when press each space

Transform meatballSlots;
GameObject meatball;
int slotNum = 0;

private void Update() {
    if (Input.GetKeyDown(KeyCode.Space)) {
        Instantiate(meatball, meatballSlot[slotNum++]);
    }
}

This will create the meatball at the next slot each time you press space. Is this what you’re looking for?