Multiple variables challenge

I will try to ask my question via sample code

$TeamsSettings = get-teams #I can run this line only once for some specific reasons
Function one{
foreach ($team in $TeamsSettings ){
$teamid= $team.Id
$settings = get-settings | {$_.teamid - $teamid} # this can be run only once in a script
new-variable -Name “settings${teamid}” -Value $settings -Scope script #I need to use this variable in second function
#e.g for this team, settings are stored in variable $settings3838
}}

Function two{
foreach ($team in $TeamsSettings ){
$teamid= $team.Id #I use this to determine second part of the variable name from first function to get right value for this team
$settings${teamid} # I need to get variable value from first function (e.g. $settings3838) for each team but I’m not sure how
}}