Get a USkeletalMeshComp from a weapon to Set another mesh C++

Hey everyone! First thank you for reading. Well thats the situation hah.
When my character dies I need to spawn a new “Dropped gun” actor, with just the name of the character weapon and the mesh of it. Im doing that to dont have a weapon with all funcionality on the ground and drop to the floor just a mesh.

I tried this but without success:

for (int i = 0; i < CharacterWeapons.Num(); i++)
{
USkeletalMeshComponent* WeaponMesh = CharacterWeapons[i]->FindComponentByClass();

	ADroppedWeapon* DroppedGun = GetWorld()->SpawnActor<ADroppedWeapon>(DroppedGunClass,
																		CharacterWeapons[i]->GetActorLocation(),
																		CharacterWeapons[i]->GetActorRotation());

	USkeletalMeshComponent* DroppedWeaponMesh = DroppedGun->FindComponentByClass<USkeletalMeshComponent>();
	DroppedWeaponMesh->SetSkeletalMesh(Cast<USkeletalMesh>(WeaponMesh));



	UE_LOG(LogTemp, Warning, TEXT("Spawning dropped gun"));
}

Cause to less space here the code has the same order but not the same look. Im new here in UE5 and If you have advice about my idea or an idea better than mine, I would appreciate it if you share it with me. Thank you!