Widget for apple and coin and turn map

I need help. I created a HUD widget and I’d like to connect it to pickup items. When a player picks up a red apple, it adds +1; a purple apple adds +10; and a gold apple adds +100. The total should accumulate in the widget. Later, the player can interact with an NPC to convert apples into coins, and those coins can be used to purchase any item on the map

Hey @Secretmoon04 how are you?

The best way to do something like this is by adding gameplay tags to your item spawners depending on the item they will spawn in game. You can see how to do that in this link. You will need to create three different tags for each fruit color and assing those tags to the Item Spawners that will spawn the fruit of the corresponding color.

Then, in your “OnBegin”, get all your item spawner devices with the same tag and subscribe to “ItemPickedUpEvent” with the corresponding function. You will need one function for each value (+1, +10, or +100).

In each of those functions, you will want to add the pickup score to an int variable that belongs to the corresponding player, and then update the UI with that int value for the corresponding player. To track the points for each player you can use a map, here you have the documentation for that.

That should work for the UI, now for the shop/exchange you will need to subtract from the variable mentioned in the previous point and update the UI again with the new value. Here you have a video that can help you to create the store.

Hope this helps you reach your goal!

thank you