Manipulating the player's inventory?

I’m trying to make a mod that adds trading with AI through the use of gold and silver. So far I have a basic UI and with a single “Buy” button. All I have is cementing paste which costs 5 gold. How do I check if the player has 5 gold, and remove it? I think I know how to add the cementing paste since it’s just a single one. I know how to check if the player has any gold at all, but I don’t know how to check how much they have.

Here’s a picture of my blueprint so far:

Change Gold To A Variable, Then Check That Variable For The Amount And Return A Boolean.

Gold is a variable, but I think it might be null… Is there any way for me to just set it equal to PrimalItemResource_Gold then just check every value in the inventory array for that? I’m really bad at explaining things so bare with me here. Also I’m really new to visual programming, normally I’d try doing it through normal programming, but that doesn’t seem to be an option.

PS: Since posting this I’ve effectively redone this graph.

What I’m thinking would work is make a few counters, and set up a foreachloop to run through the inventory items. Then every time it finds an instance of PrimalItemResource_Gold, it adds to one of the counters. Once the loop is done it checks to make sure there is at least 5 gold, then goes back and removes 5 of the instances of gold.

I’ve kind of started trying that, but I think the variable “Gold” might be null…

Do you think that would work, and if so what should I do next?