Widget text bidning not updating correctly.

Trying to make a little clicker game for fun. Whenever I press the button to purchase a building the cost that is 1 is under the new updated cost that is 2. I have tried for a day and a half for different solutions and looking over other forum posts for similar problems. Any assistance with this problem would be very appreciated.

What are you possibly creating a new widget each time you “purchase” something? It seems you have a widget on top of a widget. How do you create and add this widget to the viewport?

Dont store the variables that are changing in the widget. Store them somewhere else like in the Game Instance for example. Then if you destroy the widget or make a new one the values are still there.

Why can’t you have the variable in the widget? I’m having a similar issue, I have the game mode in charge of the the change in mine. It set the variable after the widget has been created but that first setting sticks around when I change it using the same method to first set it. And no new overlaps with further calling of the method.

If you’re going to be creating and destroying your widgets then storing variables in them isn’t wise since they won’t be remembered once the widget is destroyed. You can’t update the values from one created widget to another if the widget itself stores the variable you are trying to modify.

That’s true. You can keep the values in the widget itself if the widget is not being destroyed between changes.