You HUD needs a reference to Cube_Blueprint, where are you adding the widget to the viewport? And where is the Cube_Blueprint in the beginning of the game?
You won’t actually need the cast at all if it is a reference to the actor. I’m not sure how you’re doing this, but say for example your Cube_Blueprint exists in the map, and you adding your HUD to the viewport on BeginPlay in your level blueprint, you could do the below:
- Add a new variable to your HUD, of type Cube_Blueprint Reference, make it editable and exposed on spawn by clicking these checkboxes:

- In your level you have Cube_Blueprint, and you are adding the widget to the viewport in the level blueprint:
- Then back in your HUD widget in your GetText function, you can do this without a cast:
This might not apply specifically to you, but basically, you need a reference to you cube_blueprint in order to get the score from it. And there’s a lot of different ways of doing this. But if you can avoid using GetAllActorsOfClass, or casts, in your GetText function, that is ideal.

