That is a method for a
Player object. I don't know if it can be used in a map script because the map is generated before the game starts, so when it is running there would be no Players; or at least if there are Players, they wouldn't yet have any units.