AttachToComponent C++ not Working

Hello, I don’t understand why AttachToComponent() is not working.

I have basic VR Pawn like so:
image

What I want to do at the BeginPlay() function is to spawn and attach some cards to my PlayerDeck Component.

Here is my code in my Pawn class BeginPlay function:

void AMyPlayer::BeginPlay()
{
	Super::BeginPlay();
	stateDeck = DECK_CLOSE;
	
	FVector loc = LeftHandMesh->GetComponentLocation();
	FRotator rot = LeftHandMesh->GetComponentRotation();

	for (int i = 0; i < 8; i++)
	{
		ACard* newCard = dynamic_cast<ACard*>(this->GetWorld()->SpawnActor(ACard::StaticClass(), &loc, &rot));
		playerCards.Add(newCard);
	}
	int i = 0;
	for (ACard* elem : playerCards)
	{ 
		elem->getStaticMeshComp()->SetRelativeTransform(positionCardPlayer[i]);
		elem->getStaticMeshComp()->AttachToComponent(PlayerDeck, FAttachmentTransformRules::KeepRelativeTransform);
		elem->getStaticMeshComp()->SetSimulatePhysics(false);
		i++;
	}
	
}

My ACard class inherit from an ACollectible class who inherit from AActor.

I really don’t understand why it is not working because on my Grib function I made I use AttachToComponent and it’s working… as you can see here:

void AMyPlayer::gripObject()
{
	AActor* cActor = NULL; //here to find the closet object if their is one overlapping
	TArray<AActor*> overlapping;
	RightControllerCollision->GetOverlappingActors(overlapping);

	for (AActor* elem : overlapping)
	{
		if (cActor == NULL && elem->GetClass()->IsChildOf(ACollectible::StaticClass()))
		{
			cActor = elem;
		}
	}

	if (cActor != NULL)
	{
		ACollectible* gActor = dynamic_cast<ACollectible*>(cActor);
		gActor->getStaticMeshComp()->AttachToComponent(RightController, FAttachmentTransformRules::KeepWorldTransform);
		gActor->getStaticMeshComp()->SetSimulatePhysics(false);
	}
}

I tried changing the AttachementTransformRules but whithout results. I check if the function is called and it is.
I also tried to spawn one card and attach it to the player deck directly in a function which need to be trigger by a button and it’s not working either…

If anyone have an idee or know why it is not working I will be grateful.
Thanks

So, I’m back after letting this issue aside for a while.
I managed to resolve the problem by creating an other Actor class to replace my “DeckPlayer” component.
The class I created is really simple, I just put an empty staticMeshComponent for the rootComponent.
In my player class, on top of the beginplay function, I created a newObject of type “theClassICreated”, I then attached it to my LeftHandMesh.
Then The cards I spawned, I attached them to the root/StaticMeshComp of the actor “theClassICreated” and it did work.
So I think the cards needed to be attached at the root of an actor, not sure why but it’s working now.