Unable to Create Widget, no outer provided

Hey,

I’m getting an error trying to grab a blueprint widget in c++ and spawn it. This is the error provided

230115-error.png

My code is as follows:

And the blueprint is found in this folder

What is wrong with my code?

Use the first line that you commented with FObjectFinder. Access you hud reference like this HUD.Object

And how do I go about using Create Widget with that?
both
MainHUD = CreateWidget(GetWorld(), HUD);
and
MainHUD = CreateWidget(GetWorld(), HUD.Object); result in compile failed with the reason being

This also happens when using FObjectFinder

Doesn’t matter if i use this
static ConstructorHelpers::FObjectFinder HUD(TEXT(“WidgetBlueprint’/Game/HUDs/MainUI_HUD.MainUI_HUD’”));
or
static ConstructorHelpers::FObjectFinder HUD(TEXT("/Game/HUDs/MainUI_HUD"));

I’ve got it working follow this advice found in Cook an unreferenced Widget Blueprint - C++ Programming - Unreal Engine Forums

Here is my end code to get a UMG Widget Blueprint found and spawned using C++

230132-playercontrollerh.png