I created a system where I can pick up coins and they are saved but I cant spend them



My coins aka bottles can be picked up and are able to be saved. The only problem is that I don’t know how to set up a system for buying things with the coins on a button clicked in the widget. Can anyone show me how to do it.

Hello,

Try when opening a shop menu to get this coins variable from saved file and set it to the variable, and then perform actions (like spending) on this new variable in your menu.After performed action save this value again.


An example on settings

Hope it can help you

Is the settings supposed to represnt my bottlesave game bp or do I have to create an entirely new bp and if so what type? This can all take place in the widget right? And so I know u want me to set my saved game bottleamount as a new variable so Im able to use it in my widget but how do I specifically do that. I feel like it has something to do with my first question. I just need a little more guidence because Im fairly new plz.

In general, the “save” BP should only be used when saving/loading games.

The state you want the player to have, should typically live in PlayerState, or for certain cases in the player Pawn. Hit points, for example, can live on the Pawn, because that particular pawn is the one taking the hits. But collectibles belong on the player not the pawn and thus should live in PlayerState.

So, When you collect bottles, increment some value in your PlayerState.
When you save the game, read the value out of your PlayerState, and write it in the savefile.
When you load the game, read the value from the savefile, and write it back to the PlayerState.
When the player somehow triggers a purchase screen, make sure the widget has a reference to the PlayerState, so that the purchase screen can read/write the amount of bottles.

How you hook up the PlayerState to the shop widget is up to you, but typically this will be done from the PlayerController that is used to detect/command that the purchasing UI shows up, and creates the widget in the first place. After creating the widget (or as a spawn/construction parameter for the widget,) you could provide the PlayerController to the widget.