# Give player item on Custom Zombie elimination

**URL:** <https://forums.unrealengine.com/t/give-player-item-on-custom-zombie-elimination/2335699>\
**Category:** Verse\
**Tags:** unreal-editor-for-fortnite, fortnite-creative, question, fortnite\
**Created:** [February 16, 2025, 2:07am UTC](https://forums.unrealengine.com/t/give-player-item-on-custom-zombie-elimination/2335699 "2025-02-16T02:07:55Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![SniketTheLlama](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@SniketTheLlama](https://forums.unrealengine.com/u/SniketTheLlama)\
**Post date:** [February 16, 2025, 2:07am UTC](https://forums.unrealengine.com/t/give-player-item-on-custom-zombie-elimination/2335699/1 "2025-02-16T02:07:55Z")

</div>

Can’t figure out how to give a player anything after eliminating a custom zombie. I understand that the CustomPlayer.Collect would fail at the the end because the agent here is the custom zombie. Am I misunderstanding that? The code that displays the message from the HUD\_Message\_Device only displays if set to show all instead of triggering player.

```auto
CustomZombie_Manager := class(creative_device):

    GameManager : Game_Manager = Game_Manager{}

    @editable ZombieSpawners : []creature_spawner_device = array{}
    @editable CustomProp1 : creative_prop_asset = DefaultCreativePropAsset
    @editable ZombieElimCurrency : float = 5.0
    @editable ElimMessage : hud_message_device = hud_message_device{}

    @editable ElimTrigger : trigger_device = trigger_device{}

    OnBegin<override>()<suspends>:void=
        for(Spawner : ZombieSpawners):
            Spawner.SpawnedEvent.Subscribe(OnSpawned)
        ElimTrigger.TriggeredEvent.Subscribe(OnTriggered)

    OnSpawned(ZombieAgent : agent) : void=
        if(FC := ZombieAgent.GetFortCharacter[]):
            FC.Hide()
            if(NewProp := SpawnProp(CustomProp1 , FC.GetTransform().Translation, FC.GetTransform().Rotation)(0)?):
                spawn:
                    TrackZombie(NewProp , ZombieAgent)

    TrackZombie(Prop : creative_prop, Agent : agent)<suspends> : void=
        if(FC := Agent.GetFortCharacter[]):
            race:
                block:
                    FC.EliminatedEvent().Await()
                    ElimTrigger.Trigger(Agent)
                    Prop.Dispose()
                    return
                loop:
                    Sleep(0.0)
                    ZombiePos := FC.GetTransform().Translation
                    ZombieRot := FC.GetTransform().Rotation
                    spawn{Prop.MoveTo(ZombiePos,ZombieRot , 0.1)}

    OnTriggered(Agent : ?agent):void=
        ElimMessage.Show()
        if(Player:= player[Agent?], CustomPlayer := GameManager.PlayersMap[Player]):
            CustomPlayer.Collect(ZombieElimCurrency, "Resource2")

```

---

<div class="post-metadata">

**Author:** ![Mineblo](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/mineblo/32/1203575_2.png) [@Mineblo](https://forums.unrealengine.com/u/Mineblo)\
**Post date:** [February 16, 2025, 8:33am UTC](https://forums.unrealengine.com/t/give-player-item-on-custom-zombie-elimination/2335699/2 "2025-02-16T08:33:28Z")

</div>

> [@SniketTheLlama](#):
>
> The code that displays the message from the HUD\_Message\_Device only displays if set to show all instead of triggering player.

> [@SniketTheLlama](#):
>
> `ElimMessage.Show()`

When using the .Show Function for the Hud Message Device if you want it to show for a specific player you will need to provide the player as a paremeter eg .Show(Agent)  
since you have an agent optional which means when the function is run there may or may not be a provided player you will need to handle that and place it under an if condition that checks for the player

```auto
if(RealAgent:=Agent?):
    ElimMessage.Show(Agent)

```

Essentially inside the if runs the elimmessage.show only if there is an agent provided and if there is it names that as a constant named RealEgent (You can change that name)

---

<div class="post-metadata">

**Author:** ![SniketTheLlama](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@SniketTheLlama](https://forums.unrealengine.com/u/SniketTheLlama)\
**Post date:** [February 16, 2025, 3:32pm UTC](https://forums.unrealengine.com/t/give-player-item-on-custom-zombie-elimination/2335699/3 "2025-02-16T15:32:16Z")

</div>

Thank you for explaining that. The code that comes after for CustomPlayer.Collect does not do what it should. I am testing it out and I get nothing after eliminating my custom zombies.

Would you happen to know why and what I can do to fix that?

---

<div class="post-metadata">

**Author:** ![SniketTheLlama](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@SniketTheLlama](https://forums.unrealengine.com/u/SniketTheLlama)\
**Post date:** [February 17, 2025, 3:35pm UTC](https://forums.unrealengine.com/t/give-player-item-on-custom-zombie-elimination/2335699/4 "2025-02-17T15:35:41Z")

</div>

I did try to add Agent to the ElimMessage.Show() and got an error. I’m not too concerned with this part as I am with giving the eliminating player currencies for the elimination. How can I get the eliminating player so that I can give them stuff?

 ![Code_7qzSnDcNSR](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/2/c/62cfd4d0c466db6ff1d69d261cf85845d3bccd1a.png)

---

<div class="post-metadata">

**Author:** ![Mineblo](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/mineblo/32/1203575_2.png) [@Mineblo](https://forums.unrealengine.com/u/Mineblo)\
**Post date:** [February 18, 2025, 1:24am UTC](https://forums.unrealengine.com/t/give-player-item-on-custom-zombie-elimination/2335699/5 "2025-02-18T01:24:17Z")

</div>

```auto
if(RealAgent:=Agent?):

```

You need to have this ^ and then whenever an agent is needed you pass RealAgent instead

---

<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:** [March 20, 2025, 1:25am UTC](https://forums.unrealengine.com/t/give-player-item-on-custom-zombie-elimination/2335699/6 "2025-03-20T01:25:05Z")

</div>

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