Simple way to target individual players?

Hi!! I think there is a way to do this but I don’t remember exactly how, I have a 4 player game with 4 teleporters that I want to trigger on them but the way I currently do it is super long code wise. What I want to do is make it so I can do a for loop and use one number to represent the sequence of teleporters and the matching player number. I’m not really sure if that makes sense I hope I’ve represented my idea well in the code. My main hope is someone way better than me at Verse recognizes my thought process and can point my in the right direction of applying it, thanks!! :smiley:

@editable Teleporters : []teleporter_device = array{}

var Number : int = 0

for(0..AllPlayers.Length - 1):
     Teleporter[Number].Teleport(Player[Number])
     set Number = Number + 1

You could make a map that links a player agent to a teleport device and initialize it in OnBegin using a for loop

var PlayerTeleporterMap : [agent]teleporter_device = map{}

....

AllPlayers := GetPlayspace().GetPlayers()
        for (X -> GamePlayer : AllPlayers):
            if(set PlayerTeleporterMap[GamePlayer] = Teleporters[X]):
                Print("Debug: Linked portal to player")

....

#Then you can do
for (GamePlayer : AllPlayers):
    if(TempPortal := PlayerTeleporterMap[GamePlayer]):
        TempPortal.Teleport(GamePlayer)

You would need to adjust this as to not get a index out of bounds at runtime.