Solved: No Need to Pass the Index!
I was trying to pass an ItemIndex parameter to determine which item to purchase, but I couldn’t get it to work. Instead of forcing the index, I found a better solution: removing the need for it entirely.
Solution:
Instead of passing an index, I store the necessary item data inside an instance of my ItemPurchase class. Now, when the purchase function is called, it already knows which item to process.
How I Fixed It: Create an instance of ItemPurchase with the item data: ItemPurchaseInstance := ItemPurchase{Item_Data := Item, ItemConditional := ItemConditional}
Subscribe the ItemPurchase function to the button click event: PurchaseButton.OnClick().Subscribe(ItemPurchaseInstance.Purchase)
Modify the Purchase method to work without an index:
Why This Works? No need to pass an index—each instance already knows which item it handles. The code is simpler and easier to maintain. The purchase function works directly without extra parameters.