# How to subscribe to TriggeredEvent?

**URL:** <https://forums.unrealengine.com/t/how-to-subscribe-to-triggeredevent/1752007>\
**Category:** Programming & Scripting\
**Tags:** fortnite-creative, unreal-editor-for-fortnite, question, fortnite\
**Created:** [March 14, 2024, 6:36pm UTC](https://forums.unrealengine.com/t/how-to-subscribe-to-triggeredevent/1752007 "2024-03-14T18:36:29Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![dragonflii](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@dragonflii](https://forums.unrealengine.com/u/dragonflii)\
**Post date:** [March 14, 2024, 7:06pm UTC](https://forums.unrealengine.com/t/how-to-subscribe-to-triggeredevent/1752007/3 "2024-03-14T19:06:43Z")

</div>

> [@BraveGamerTV](#):
>
> ```auto
> OnTriggeredEvent<private>(Reading : string)<suspends>:void=
> MapText.SetText(StringToMessage("Castaway Castles"))
> DifficultyText.SetText(StringToMessage("EASY"))
> 
> ```

The error describes the problem. The handler function signature must match what the event expects. Like so:

```auto
OnTriggeredEvent<private>(Agent: ?agent):void=

```

(Note that `<private>` is only allowed inside a class - watch indents.)  
If you want to pass extra data to the handler, you can use a wrapper (similar code is available in the snippets section.)

```auto
(Listenable : listenable(?agent)).SubscribeAgentVoid(Out : tuple(?agent, t)->void, MyData : t where t:type) : cancelable =
  Wrapper := wrapper_agentvoid(t){MyData := MyData, Out := Out}
  Listenable.Subscribe(Wrapper.In)

wrapper_agentvoid(t : type) := class():
  MyData : t;
  Out : tuple(?agent, t) -> void
  In(Agent : ?agent):void = Out(Agent, MyData)

```

Which you could then use like this:

```auto
TriggerCancelable : cancelable = Trigger.TriggeredEvent.SubscribeAgentVoid(OnTriggeredEvent, "Your String")

```

Or check this out:

[Guide to Event Subscribing with Additional Parameters (Handler Functions) - Programming & Scripting / Verse - Epic Developer Community Forums (unrealengine.com)](https://forums.unrealengine.com/t/guide-to-event-subscribing-with-additional-parameters-handler-functions/793925)

---

_[View the full topic](https://forums.unrealengine.com/t/how-to-subscribe-to-triggeredevent/1752007)._
