Widget variable keeps resetting in blueprint on compile

Hi. I have a player controller class on which i have created a pointer of type Widget. When i create a blueprint based off my code and try to assign a Widget_blueprint (previously created) into it and compile the variable always gets reset to none. I Don’t know what i am doing wrong. Here’s My Code


// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/PlayerController.h"
#include "MyPlayerController.generated.h"

class DARKHORSEUNREAL_API AMyPlayerController : public APlayerController


	//Begin Play Function
	virtual void BeginPlay() override;

	//Tick Function
	virtual void Tick(float DeltaTime) override;

	class UUserWidget* InfoWidget;


// Fill out your copyright notice in the Description page of Project Settings.

#include "MyPlayerController.h"
#include "Blueprint/UserWidget.h"

	// Set this character to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
	PrimaryActorTick.bCanEverTick = true;


void AMyPlayerController::BeginPlay()

	if (InfoWidget)

void AMyPlayerController::Tick(float DeltaTime)

did you set the variable on beginplay or constructor?
try setting it on constructor

I have just created a pointer in the c++ code. and i am creating a blueprint off the code and then assigning the widget blueprint into the variable through blueprint.

what event/function are you using on blueprint to save the reference?
Maybe your .cpp beginplay is already getting executed before you set your variable
try setting it on the constructor
Send a screenshot of the blueprint

I am having this exact same issue with version 4.25.4. Did you ever find a resolution for this?