# GetSocketByName() returns nullptr

**URL:** <https://forums.unrealengine.com/t/getsocketbyname-returns-nullptr/424937>\
**Category:** C++\
**Tags:** nullptr, unreal-engine, crash, UE4, question, CPP\
**Created:** [May 12, 2018, 11:59am UTC](https://forums.unrealengine.com/t/getsocketbyname-returns-nullptr/424937 "2018-05-12T11:59:06Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Klaub](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Klaub](https://forums.unrealengine.com/u/Klaub)\
**Post date:** [May 12, 2018, 11:59am UTC](https://forums.unrealengine.com/t/getsocketbyname-returns-nullptr/424937/1 "2018-05-12T11:59:06Z")

</div>

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!
