UEFN - This function parameter expects a value of type ?agent->void

I was following along with Epic’s UI Tutorial and decided to add my own custom touches to it. Where the player would be prompted with a button but I’m getting forced with this error and I when I change it to (Player : ?agent) it still doesn’t work. What is the difference and what can I do to fix it?

2 Likes

the code seems to work but you said you already tried with ?agent?

CreatureSpawner is a creature placer device correct?

the code seems to work on my end

    OnBegin<override>()<suspends>:void=
        CreatureSpawner.EliminatedEvent.Subscribe(Eliminated)
        
    Eliminated(Agent : ?agent) : void = 
        Print("Creature Eliminated!")
1 Like

Sorry for the late reply! Yes this is the Creature Placer device and yes I’ve tried with ?agent. I’ll double check over the work and try again!

I had the same issue, using agent? works for function argument, but how do you later cast it to player? This is what I’m having so far:
image

Okay, found the solution myself - Option type
This is the code that works without compilation errors (added ? after the Agent):
image

2 Likes

Hi - I am a little confused because the final code did not include the Spawner device or EliminatedEvent. Can you clarify what fixed that part of the code?