Code for NPCs to follow the nearest of the Team 1 players

Hello.
I want to use the verse device and create a code to make the NPCs work to follow the nearest player among the Team 1 players, but it does not start up properly.
How do I make the change?
Thank you.

using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /Fortnite.com/AI }
using { /Fortnite.com/Characters }

A Verse-authored creative device that can be placed in a level

follower_example_device := class(creative_device):

@editable
FollowerSpawner:npc_spawner_device = npc_spawner_device{}

var MaybePlayer:?player = false
# Runs when the device is started in a running game
OnBegin<override>()<suspends>:void=
    # Get all players in game
    var Players:[]player = GetPlayspace().GetPlayers()
    var ClosestPlayer:?player = false
    var MinDistance:float = 1000000.0  # 初期値を非常に大きな値に設定
    
    # Find the closest player from team 1
    AllPlayers := GetPlayspace().GetPlayers() 
        if players.GetTeam() = 1:
            var Distance:float = Player.GetLocation().DistanceTo(FollowerSpawner.GetLocation())
            if Distance < MinDistance:
                set MinDistance = Distance
                set ClosestPlayer = option{Player}
    
    set MaybePlayer = ClosestPlayer
    
    # Connect behavior to leash guards to player when they spawn
    FollowerSpawner.SpawnedEvent.Subscribe(OnFollowerSpawned)

# Have guards leashed to player when they're spawned
OnFollowerSpawned(Follower:agent):void=
    if:
        FollowerLeash := Follower.GetFortCharacter[].GetFortLeashable[]
        Player := MaybePlayer?
    then:
        # Player is center of the leash
        # InnerRadius and OuterRadius define the range for the guards to try to stay in
        FollowerLeash.SetLeashAgent(Player, InnerRadius := 10.0, OuterRadius := 500.0)