Make a prop follow the instigator player

Im trying to make a code that follows the current instigator of the trigger , it suppost to change the player once a new instigator active it, but now i dont have any visual error but and isnt working


using { /Fortnite.com/Devices }
using { /Fortnite.com/Characters }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/SpatialMath }
using { /UnrealEngine.com/Temporary/Diagnostics }

# See https://dev.epicgames.com/documentation/en-us/uefn/create-your-own-device-in-verse for how to create a verse device.

# A Verse-authored creative device that can be placed in a level
seguir_jugadores := class(creative_device):
   @editable MyTrigger : trigger_device = trigger_device{}
   @editable Prop : creative_prop = creative_prop{}

   var SelectedPlayer : []fort_character = array{}
   var StopChasing : logic = false
  
   OnBegin<override>()<suspends>:void=
       MyTrigger.TriggeredEvent.Subscribe(HandleTrigger)
       ChasePlayer(Prop)



   HandleTrigger(MaybeAgent:?agent):void=
       if(Agent:=MaybeAgent?,Player:=Agent.GetFortCharacter[]):
           if(set SelectedPlayer[0] = Player){}
       
            

   ChasePlayer(Enemy : creative_prop)<suspends>:void=
       var PreviousTime : float = GetSimulationElapsedTime()
           MoveSpeed := 0.1

           loop:
               Sleep(0.0)
               if(PlayerCharacter := SelectedPlayer[0]):
                      
                       CurrentTime := GetSimulationElapsedTime()
                       DeltaTime := CurrentTime - PreviousTime
                       set PreviousTime = CurrentTime
                       PropLocation := Enemy.GetTransform().Translation
                       PlayerLocation := PlayerCharacter.GetTransform().Translation
               
                        if (LookDirection := (PlayerLocation - PropLocation).MakeUnitVector[]):
               
                           Yaw := RadiansToDegrees(ArcTan(LookDirection.Y, LookDirection.X)) - 90.0
                           Pitch := 0.0 #RadiansToDegrees(ArcTan(LookDirection.Z, Sqrt((LookDirection.X * LookDirection.X) + (LookDirection.Y * LookDirection.Y))))
                           Roll := 0.0
               
                           NewRotation := MakeRotationFromYawPitchRollDegrees(Yaw, Pitch, Roll)
               
                                   # Movement
                           LerpLocation := Lerp(PropLocation, PlayerLocation, DeltaTime * MoveSpeed)
                           FinalLocation := vector3{X := LerpLocation.X, Y := LerpLocation.Y, Z := 0.0}
               
                           if:
                            Enemy.TeleportTo[FinalLocation, NewRotation]
1 Like

call ChasePlayer(Prop) from within Handle Trigger, you are losing your Agent scope by doing it outside of the listener