Recreating Blueprint Function In C++ | Spawning Actors

void AMyGM::SpawnOrbs()
{
	TArray<TObjectPtr<AActor>> MySpawnPointArray;
	UGameplayStatics::GetAllActorsOfClass(GetWorld(), ASpawnPoint::StaticClass(), MySpawnPointArray);

	for (int32 i = 0; i <= 9; ++i)
	{
		if (MySpawnPointArray.IsEmpty()) break; // Stop loop if empty.
		
		const int32 index = FMath::RandRange(0, MySpawnPointArray.Num() - 1);  // int32 rather than a reference to later avoid searching the array.

		GetWorld()->SpawnActor<AMyOrbClass>(
			MySpawnPointArray[index]->GetActorLocation(), 
			MySpawnPointArray[index]->GetActorRotation()
		);
		
		MySpawnPointArray[index]->Destroy(); // Destroy actor.
		MySpawnPointArray.RemoveAtSwap(index); // Swap to last and remove.
	}
}

Hope it helps