Figuring out which team captured the objective

I have a simple map with a capture device and cylinder.
There are 2 teams playing the game. If someone from team 1 captures the cylinder it turns green, if someone from team 2 does, it turns orange.

I’m trying to make this work in Verse.

Steps:

  1. I use 2 x team_settings_and_inventory_device and set 1 to teamindex 1 and the other to teamindex 2
  2. I subscribe to the capture device’s “OnControlChangeEvent” event.
    In the event I use some code I found in an example:
    TeamCollection := GetPlayspace().GetTeamCollection()
    if (AgentsTeam := TeamCollection.GetTeam[Agent]):
    TeamArray := TeamCollection.GetTeams()
    for (TeamNumber->Team : TeamArray):
    if (AgentsTeam = Team):
    if(TeamNumber = 0):
    # *** Make cylinder green ***
    else if(TeamNumber = 1):
    # *** Make cylinder orange ***

This works most of the time but not always.
Issue is that there seems to be no correlation between the team index on the team settings device and the team / agent that captured the prize.
The team number above is an index of an array which has a 50/50 chance of being in the correct order.

I have also tried using the “IsOnTeam[Agent]” of the team_settings_and_inventory_device but that always returns ‘false’.

Any help would be appreciated.