Detecting when a guard has been eliminated.

@ok_studios post identified the issue exactly.

If you’d like another example of this in action you can look at the Stronghold Template from within the UEFN Feature Examples.
Here’s a snippet from the stronghold_bark_manager.verse script that shows handling the Eliminated Event and declaring the OnGuardEliminated which would be the same as your OnAIDeath function.

Many of your typical applicated can be found in this project and it’s various verse scripts.

Hope this helps.

#call this SubscribeToGuardSpawnerEvents function in your OnBegin function
 SubscribeToGuardSpawnerEvents(GuardSpawnerDevice:guard_spawner_device):void = 
        GuardSpawnerDevice.DamagedEvent.Subscribe(OnGuardDamaged)
        GuardSpawnerDevice.EliminatedEvent.Subscribe(OnGuardEliminated)
        GuardSpawnerDevice.EliminatingEvent.Subscribe(OnPlayerEliminated)

#an example of doing something when a guard is eliminated, like playing a sound effect device
 OnGuardEliminated(InteractionResult:device_ai_interaction_result):void=
        if (EliminatedGuard := InteractionResult.Target?):

            # Find closest alive guard to play this bark
            var ClosestGuard:?agent = false
            if:
                set ClosestGuard = option{StrongholdGameManager.AlertedGuards[0]}
                EliminatedGuardCharacter := EliminatedGuard.GetFortCharacter[]
            then:
                for (AlertedGuard : StrongholdGameManager.AlertedGuards, AlertedGuardCharacter := AlertedGuard.GetFortCharacter[]):
                    if:
                        not ClosestGuard? = AlertedGuard
                        ClosestGuardCharacter := ClosestGuard?.GetFortCharacter[]
                        DistanceSquaredToAlertedGuard := DistanceSquared(AlertedGuardCharacter.GetTransform().Translation, EliminatedGuardCharacter.GetTransform().Translation)
                        DistanceSquaredToClosestGuard := DistanceSquared(ClosestGuardCharacter.GetTransform().Translation, EliminatedGuardCharacter.GetTransform().Translation)
                        DistanceSquaredToAlertedGuard < DistanceSquaredToClosestGuard
                    then:
                        set ClosestGuard = option{AlertedGuard}

            if (Guard := ClosestGuard?):
                spawn {BarkNPCDown.PlayBark(Guard)}