# Once the trigger is activated, I want to retrieve the item from the item granter.

**URL:** <https://forums.unrealengine.com/t/once-the-trigger-is-activated-i-want-to-retrieve-the-item-from-the-item-granter/2166649>\
**Category:** Verse\
**Tags:** unreal-editor-for-fortnite, question, fortnite\
**Created:** [December 3, 2024, 7:46am UTC](https://forums.unrealengine.com/t/once-the-trigger-is-activated-i-want-to-retrieve-the-item-from-the-item-granter/2166649 "2024-12-03T07:46:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![renzymode](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@renzymode](https://forums.unrealengine.com/u/renzymode)\
**Post date:** [December 3, 2024, 7:46am UTC](https://forums.unrealengine.com/t/once-the-trigger-is-activated-i-want-to-retrieve-the-item-from-the-item-granter/2166649/1 "2024-12-03T07:46:30Z")

</div>

I want to make a player retrieve the item from the item granter once the trigger is activated.  
But the trigger event needs a ?agent and the item granter needs an agent, and I can’t pass arguments to the function properly.  
How can I do this?  
The code is as follows.  
Thank you in advance for your help.

using { /Fortnite.com/Devices }  
using { /Verse.org/Simulation }  
using { /UnrealEngine.com/Temporary/Diagnostics }

sample\_granter\_device := class(creative\_device):

```
@editable
ItemGranter:item_granter_device=item_granter_device{}

@editable
PlayerSpawners:[]player_spawner_device = array{}

@editable
Trigger:trigger_device = trigger_device{}

OnBegin<override>()<suspends>:void=
    Players := GetPlayspace().GetPlayers()
    for (Player : Players):
        Trigger.TriggeredEvent.Subscribe(ItemGrant)

ItemGrant(Player:agent):void = 
    ItemGranter.GrantItem(Player)

```

---

<div class="post-metadata">

**Author:** ![OddMyth](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@OddMyth](https://forums.unrealengine.com/u/OddMyth)\
**Post date:** [December 3, 2024, 8:55am UTC](https://forums.unrealengine.com/t/once-the-trigger-is-activated-i-want-to-retrieve-the-item-from-the-item-granter/2166649/2 "2024-12-03T08:55:19Z")

</div>

You need to change the argument type for Player from agent to ?agent.

> [@renzymode](#):
>
> ```auto
> ItemGrant(Player:agent):void = 
> ItemGranter.GrantItem(Player)
> 
> ```

```auto
ItemGrant(Player:?agent):void = 

```

You will then need to check the ?agent is valid, with something like:

```auto
ItemGrant(Player:?agent):void = 
   if(Checked_Player := Agent?):
       ItemGranter.GrantItem(Checked_Player)

```

More info on Optional:

> **[Option | Unreal Editor for Fortnite Documentation | Epic Developer Community](https://dev.epicgames.com/documentation/en-us/uefn/option-in-verse)**
>
> The option type can contain one value or can be empty.

---

<div class="post-metadata">

**Author:** ![renzymode](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@renzymode](https://forums.unrealengine.com/u/renzymode)\
**Post date:** [December 4, 2024, 12:33am UTC](https://forums.unrealengine.com/t/once-the-trigger-is-activated-i-want-to-retrieve-the-item-from-the-item-granter/2166649/3 "2024-12-04T00:33:19Z")

</div>

Thank you very much!  
I read the page about Optional!  
I’m very happy to learn about weak\_map too!  
I had a great time! Thanks for answering my question!

---

<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:** [January 3, 2025, 12:34am UTC](https://forums.unrealengine.com/t/once-the-trigger-is-activated-i-want-to-retrieve-the-item-from-the-item-granter/2166649/4 "2025-01-03T00:34:09Z")

</div>

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