Component gets disabled when parent changed

Hello everyone !
I’m struggling with something I don’t understand : I am working on a card game, in which all the cards are gameobjects instantiated in the deck. I have a Component called CardsPile that is responsible for holding the cards together, and it is the same for the deck and the hand.

When a card is drawn, it is moved from the deck to the hand. But for some reason, some scripts attached to the card get disabled. The funny thing is that it is not the case for the first card drawn during the game…

I’m kinda lost, so this is the code that draws the cards. Remove and Add are functions to “unparent” and “parent” the card from or to a CardsPile.

    public void DrawCombatCards(int cardsToDraw)
        CardsPile hand = Hand.instance.hand;
        CardsPile combatDeck = CombatDeck.instance.combatDeck;

        for (int i = 0; i < cardsToDraw; i++)
            GameObject card = combatDeck.Cards[combatDeck.Cards.Count - 1];
            hand.Add(card, 0, false);

This is the Add and Remove code :

	public float height = 0.5f;
	public float width = 1f;
	[Range(0f, 90f)] public float maxCardAngle = 5f;
	public float yPerCard = -0.005f;
	public float zDistance;

	public float moveDuration = 0.5f;
	public Transform cardHolderPrefab;

	readonly List<GameObject> cards = new List<GameObject>();

	public List<GameObject> Cards => new List<GameObject>(cards);

	public event Action<int> OnCountChanged;

	readonly List<Transform> cardsHolders = new List<Transform>();

	bool updatePositions;
	readonly List<GameObject> forceSetPosition = new List<GameObject>();

	public void Add(GameObject card, bool moveAnimation = true) => Add(card, -1, moveAnimation);

	public void Add(GameObject card, int index, bool moveAnimation = true)
		Transform cardHolder = GetCardHolder();

		if (index == -1)
			cards.Insert(index, card);
			cardsHolders.Insert(index, cardHolder);

		updatePositions = true;

		if (!moveAnimation)


	public void Remove(GameObject card)
		if (!cards.Contains(card))

		Transform cardHolder = cardsHolders[cards.IndexOf(card)];

		updatePositions = true;


Thank you all for reading ! Take care.

Ok, I just solved it, but in my opinion this is a bug. Basically, when the parent gameObject was destroyed, every component attached to the child got disabled. So I had to move down the line responsible for destroying the parent. Voilà !