Removing objects with children from lists

I moving the object to slot object with drag and drop and when the object dropped to slot, it being child of that.
when i press next button, I want removing object with children at list but does not work. the childs of
the slots are still standing there.

for (int i = 0; i < questionData.answer.Length; i++)
        {

            GameObject slotGameObject = slotsObjectPool.GetObject();
            slots.Add(slotGameObject);
            slotGameObject.transform.SetParent(slotPanel);
        }

    void RemoveSlots()
    {
        while (slots.Count > 0)
        {
            slotsObjectPool.ReturnObject (slots [0]);
            slots.RemoveAt (0);
        }
           

    }

If I understand you correctly you want to Destroy the slots? So you should use the Destroy function provided by unity. RemoveAt just removes the object from the list. The object will still exist

slots.Clear();
foreach (Transform child in slotPanel.transform)
{
    GameObject.Destroy(child.gameObject);
}

YOU’RE MY SAVIOORRR!!! Thanks man. I love you :smile: