How do you get the sequence order of an element in a map container?

Hello,

I’m trying to get my head around maps. I have a function GetPlayerNumber, which returns a player number, which is the order they are added to the map GamePlayers.

This is the code I have so far, however always seems to return 0 even though I pass in two different players. I’m sure its something to do with the if statement but i’ve not been able to find any syntax around key->value pairs and map containers.

Any help would be greatly appreciated

GetPlayerNumber<public>(Player:player): int  =
        PlayerNumber: int = 999

        for (Index := 0..GamePlayers.Length - 1):
            if(PlayerExisting := GamePlayers[Player]):
                return Index
                
        return PlayerNumber