How do I make a custom AI NPC patrol an area and target players?

Basically I am trying to create an NPC with custom behavior that patrols an area until they spot a player, which then they target that player and once theyre close enough trigger a jumpscare. But I am a big newbie and with little to no experience in verse this is a headache, I have watched a youtube video but cannot get it to work properly.

rabbitAI := class(npc_behavior):

BehaviorHelp : behaviorhelper = behaviorhelper{}

MakeInvisible(InPlayer:agent)<suspends>: void=
    if(PlayerChar := InPlayer.GetFortCharacter[]):
        PlayerChar.Hide()
        spawn:
            MakeVisibleAfterDelay(PlayerChar)
MakeVisibleAfterDelay(PlayerChar:fort_character)<suspends>: void=
    Sleep(10.0)
    PlayerChar.Show()

OnBegin<override>()<suspends>:void=
    if:
        NPCAgent := GetAgent[]
        NPCChar := NPCAgent.GetFortCharacter[]

        NPCNav := NPCChar.GetNavigatable[]
        NPCFocus := NPCChar.GetFocusInterface[]
        NPCAnim := NPCChar.GetPlayAnimationController[]
    then:
        NPCSpawnPoint := NPCChar.GetTransform().Translation

        loop:
            Sleep(0.1)
            if(NewTarget := BehaviorHelp.FindNearestTarget[NPCChar], NewAgent := NewTarget.GetAgent[], BehaviorHelp.Perception.DeviceSeesAgentEvent):
                spawn{NPCFocus.MaintainFocus(NewAgent)}
                NavTarget := MakeNavigationTarget(NewAgent)
                NPCNav.NavigateTo(NavTarget , ?MovementType := movement_types.Running, ?ReachRadius := 150.0)
                spawn{MakeInvisible(NewAgent)}
                spawn{BehaviorHelp.JumpscareAnim(NewAgent)}

this is the main script, i have another one which also serves as a creative device so i can link the cinematic sequence device to trigger the jumpscare, which doesnt work even though ive made sure it is properly set up in game!

behaviorhelper := class(creative_device):

@editable  Jumpscare : cinematic_sequence_device = cinematic_sequence_device{}
@editable  Perception : perception_trigger_device = perception_trigger_device{}

FindNearestTarget(FC : fort_character)<decides><transacts> : fort_character =
    var MaybeTarget : ?fort_character = false
    var CheckRange : float = 5000.0
    for(Player : GetPlayspace().GetPlayers(), PlayerFC := Player.GetFortCharacter[]):
        if:
            DistanceDifference := Distance(PlayerFC.GetTransform().Translation, FC.GetTransform().Translation) < CheckRange
            not PlayerFC = FC
        then:
            set MaybeTarget = option{PlayerFC}
            set CheckRange = DistanceDifference
    return MaybeTarget?

JumpscareAnim(Agent : agent)<suspends>:void=
    Jumpscare.Play(Agent)

bump