How to change skeletal mesh in code?

With Mesh is SkeletalMeshComponent of your weapon or scope, you can call this

Mesh->SetSkeletalMesh(NewSkeletalMesh);

I want to be able to dynamically change a skeletal mesh to another skeletal mesh during gameplay. Essentially I have a weapon (skeletal mesh) and a socket which serves as the attach point for the weapon’s scope (skeletal mesh). There are many different scopes, so if the player decides to change the scope type, how can I replace the current one with a new one?

How can I change a skeletal mesh in code?

Simple answer. Thanks!