How to attach Actor Component from old actor to new actor?

Hello Friends,

I’m currently trying to attach an actor component from one actor to another via ue4 c++. I’ve been trying to use the following code, but it does not seem to work.

thisActorsComponent->AttachToComponent(otherActor->GetRootComponent(), FAttachmentTransformRules::KeepWorldTransform);

Does anyone have any recommendations for how to attach an Static Mesh Actor Component from one actor to another via C++? Thanks in advance!