# TSubclassOf returning null

**URL:** <https://forums.unrealengine.com/t/tsubclassof-returning-null/449896>\
**Category:** UI\
**Tags:** hud, tsubclassof, unreal-engine, null, Widget, question, CPP\
**Created:** [May 31, 2019, 5:10am UTC](https://forums.unrealengine.com/t/tsubclassof-returning-null/449896 "2019-05-31T05:10:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kranatos13](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@kranatos13](https://forums.unrealengine.com/u/kranatos13)\
**Post date:** [May 31, 2019, 5:10am UTC](https://forums.unrealengine.com/t/tsubclassof-returning-null/449896/1 "2019-05-31T05:10:55Z")

</div>

So I am trying to move my widgets into C++ and a HUD. I have tried watching a tutorial to get this set up though it doesn’t seem to be working for me. I set my widgets in the HUD BP using TSubclassOf and then select them in the BP itself, yet everytime I run the game I get my UE logs trigger telling me its null.

```
UPROPERTY(EditDefaultsOnly, Category = "Widgets")
TSubclassOf<UUserWidget> CombatStatusWidgetClass;

UPROPERTY(EditDefaultsOnly, Category = "Widgets")
TSubclassOf<UUserWidget> EnemyInfoWidgetClass;

```

Here is my cpp implementation.

```
void ACombatHUD::BeginPlay()
{
	Super::BeginPlay();

	if (CombatStatusWidgetClass)
	{
		CreateCombatStatusWidget();
	}
	else
	{
		UE_LOG(LogTemp, Error, TEXT("Issue with CombatStatusWidgetClass"));
	}

	if (EnemyInfoWidgetClass)
	{
		CreateEnemyInfoWidget();
	}
	else
	{
		UE_LOG(LogTemp, Error, TEXT("Issue with EnemyInfoWidgetClass"));
	}
}

```

 ![278486-hud-bp.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/2/d/82d30bf9e669289d786a1e2bac0aaf415e381a59.png)

Tried setting both the class and the BP and getting the same result each time. I know the HUD is getting called as well as BeginPlay because I am getting my errors, it is just having issues setting these attributes for some reason.

---

<div class="post-metadata">

**Author:** ![kranatos13](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@kranatos13](https://forums.unrealengine.com/u/kranatos13)\
**Post date:** [June 1, 2019, 6:50am UTC](https://forums.unrealengine.com/t/tsubclassof-returning-null/449896/2 "2019-06-01T06:50:06Z")

</div>

Figured it out. In my game mode override I set the class version of the HUD, not the blueprint version. Due to that it wasn’t finding my set classes.
