# agent and ?agent in the same function?

**URL:** <https://forums.unrealengine.com/t/agent-and-agent-in-the-same-function/1975805>\
**Category:** Verse\
**Tags:** unreal-editor-for-fortnite, fortnite-creative, question, fortnite\
**Created:** [August 14, 2024, 4:17pm UTC](https://forums.unrealengine.com/t/agent-and-agent-in-the-same-function/1975805 "2024-08-14T16:17:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![q\_e\_e](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@q\_e\_e](https://forums.unrealengine.com/u/q_e_e)\
**Post date:** [August 14, 2024, 4:17pm UTC](https://forums.unrealengine.com/t/agent-and-agent-in-the-same-function/1975805/1 "2024-08-14T16:17:14Z")

</div>

How do you guys work around this?  
when i want to subscribe to the function it asks me to have it as type of ?agent  
like here in the image

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/8/0/680ea65447eb80f2f3ec7ab9c8c5f99f4a3d5689.png)  
and when I change it to ?agent i get this error in the function  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/1/c/71c5a7c18ec93bed74d2dff995dc09ea5474c587.png)

---

<div class="post-metadata">

**Author:** ![DustinREDGames](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/dustinredgames/32/634988_2.png) [@DustinREDGames](https://forums.unrealengine.com/u/DustinREDGames)\
**Post date:** [August 14, 2024, 4:31pm UTC](https://forums.unrealengine.com/t/agent-and-agent-in-the-same-function/1975805/2 "2024-08-14T16:31:56Z")

</div>

`?` means it could have a value or be null, so you need to check if its valid first.

```auto
if:
    ValidAgent := Agent?,
    Char:fort_character = ValidAgent.GetFortCharacter[]
then:
    Char.SetHealth(Char.GetHealth() + 25.0)

```

---

<div class="post-metadata">

**Author:** ![q\_e\_e](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@q\_e\_e](https://forums.unrealengine.com/u/q_e_e)\
**Post date:** [August 14, 2024, 4:36pm UTC](https://forums.unrealengine.com/t/agent-and-agent-in-the-same-function/1975805/3 "2024-08-14T16:36:23Z")

</div>

amazing thank you

---

<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:** [September 13, 2024, 4:36pm UTC](https://forums.unrealengine.com/t/agent-and-agent-in-the-same-function/1975805/4 "2024-09-13T16:36:51Z")

</div>

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