Warning C4996: 'AActor::GetComponentsByClass': Use one of the GetComponents implementations as appropriate

Try changing

TArray<UPrimitiveComponent*> Components;

To

TArray<UActorComponent*> Components;