Hello
the problem you have is coming from the StatUMG, ie the widget used by the component.
Depending on WHEN you create the actor containing the Stat component, the setup may found a “null” reference to the Widget.
To avoid this, ensure that you are creating the Stat widget BEFORE calling the setup function. Usually, it is a good idea to create the StatsUMG in the the player controller instance (in the begin play event for example), or in a game instance.