How to access a variable from one actor to another C++

my actor where I have the variable: MyBox.h

public:

int FinishBox = 9;


from my “MyHUD” I want to access that variable that is in my actor

MyHUD.h

255543-captura.png

MyHUD.cpp

from here I want to access my variable “FinishBox” that is in the actor calling “MyBox.h”

You need to find the instance of the actor you want to access the variable of.
So something like:

AMyBox* Box;
// Get the first actor of type AMyBox.
for (TActorIterator<AMyBox> ActorIt(GetWorld()); ActorIt; ++ActorIt)
{
	Box = *ActorIt;
	break;
}
Box->FinishBox