GetSocketByName() returns nullptr

Hi, so I have a socket on my skeletal mesh called Hand_RSocket, and I’m trying to attach a static mesh subobject to it with the following code:

  const USkeletalMeshSocket* SwordSocket = this->GetMesh()->GetSocketByName(FName("Hand_RSocket"));

MySwordComponent = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("MY SWORD"));
MySwordComponent->SetupAttachment(RootComponent, SwordSocket->GetFName());

However, GetSocketByName returns a null pointer for some reason. Am I doing something wrong? Thanks!