Cant add my User Widget in the Viewport

Hi guys so im trying to make a hud appear, once a character overlap a triggerbox so heres my code, the name of my userwidget is “HelpTextHUD” i probobly forgot something but not sure what it is. so here is my code:

// .h file

// Reference UMG Asset in the Editor
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Widgets")
TSubclassOf<class UUserWidget> HelpTextHUD;

// Variable to hold the widget After Creating it.
UUserWidget* MyHelpTextHUD;

// .cpp file

		if (HelpTextHUD) // Check if the Asset is assigned in the blueprint.
		{
			// Create the widget and store it.
			MyHelpTextHUD = CreateWidget<UUserWidget>(GetWorld(), HelpTextHUD);

			// now you can use the widget directly since you have a referance for it.
			// Extra check to  make sure the pointer holds the widget.
			if (MyHelpTextHUD)
			{
				//let add it to the view port
				MyHelpTextHUD->AddToViewport();
			}
		}

any help would be appreciated thanks!! :slight_smile:

6 Years Later i was trying to find out how to display a widget from code for anyone having this problem now make sure you are adding the reference to the widget in your blueprint class