# Error (3509)

**URL:** <https://forums.unrealengine.com/t/error-3509/2415083>\
**Category:** Verse\
**Tags:** unreal-editor-for-fortnite, fortnite-creative, question, fortnite\
**Created:** [March 25, 2025, 1:05am UTC](https://forums.unrealengine.com/t/error-3509/2415083 "2025-03-25T01:05:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![\_RSK-7](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@\_RSK-7](https://forums.unrealengine.com/u/_RSK-7)\
**Post date:** [March 25, 2025, 1:05am UTC](https://forums.unrealengine.com/t/error-3509/2415083/1 "2025-03-25T01:05:57Z")

</div>

`PurchaseButton.OnClick().Subscribe(PurchaseItem(Index))`

How could I pass the index in this situation?

 ![Captura de tela 2025-03-24 191520](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/b/8/fb8a470529a8deb05688c0558378a9cd988329e6.png)

Error:  
This function parameter expects a value of type widget\_message-\>void, but this argument is an incompatible value of type void.(3509)

This function parameter expects a value of type tuple(widget\_message,int), but this argument is an incompatible value of type int.(3509)

```auto
    PurchaseItem(Message : widget_message, ItemDataIndex : int) : void =
        Player := Message.Player

        if (ShopItemConditional := ItemConditional, 
        ShopItemGranter := Item_Data[ItemDataIndex].ItemGranter, 
        Shop_Item_Price := Item_Data[ItemDataIndex].ItemPrice):
            
            KeyIndex := 0
            ShopItemConditional.SetItemCountRequired(KeyIndex, Shop_Item_Price)

            if (ShopItemConditional.HasAllItems[Player]):
                ShopItemConditional.Activate(Player)
                ShopItemGranter.GrantItem(Player)

```

---

<div class="post-metadata">

**Author:** ![\_RSK-7](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@\_RSK-7](https://forums.unrealengine.com/u/_RSK-7)\
**Post date:** [March 25, 2025, 7:16pm UTC](https://forums.unrealengine.com/t/error-3509/2415083/2 "2025-03-25T19:16:45Z")

</div>

**I found a way to solve this.**

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:  
1️⃣ **Create an instance of `ItemPurchase` with the item data:**  
`ItemPurchaseInstance := ItemPurchase{Item_Data := Item, ItemConditional := ItemConditional}`

2️⃣ **Subscribe the `ItemPurchase` function to the button click event:**  
`PurchaseButton.OnClick().Subscribe(ItemPurchaseInstance.Purchase)`

3️⃣ **Modify the `Purchase` method to work without an index:**

```auto
ItemPurchase := class:
    Item_Data : ItemData
    ItemConditional : conditional_button_device

    Purchase(Message: widget_message) : void =
        Player := Message.Player
        Item_Price := Item_Data.ItemPrice
        KeyIndex := 0
        ItemConditional.SetItemCountRequired(KeyIndex, Item_Price)

        if (ItemConditional.HasAllItems[Player]):
            Print("Purchase Item!\nPrice = {Item_Price}")
            ItemConditional.Activate(Player)
            Item_Data.ItemGranter.GrantItem(Player)
        else:
            Print("Unable to Purchase Item!\nPrice = {Item_Price}")

```

**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.

Hope this helps others facing the same issue!

---

<div class="post-metadata">

**Author:** ![system](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/1/3/713c9d3f58553f0de89543d76a8a3a2779dc9fa4.png) [@system](https://forums.unrealengine.com/u/system)\
**Post date:** [April 24, 2025, 7:17pm UTC](https://forums.unrealengine.com/t/error-3509/2415083/3 "2025-04-24T19:17:18Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
