Disable all UI elements that don't match a name

How would I make all UI elements (such as frames) that don’t match a name, invisible?

I could do something like

for _,ui in pairs ( [location] ) do 
   if (ui.Name ~= 'name') then
     ui.Visible = false

But I would like to avoid that, unless there is no other way. Let me know if there’s any other way to this.

There is no way to avoid iteration in this case. Iteration is when doing a repetitive process. And u are looking through multiple frames meaning u have to repeat by doing iteration.

If you mean while the game is running with actual GUI, you are just going to have to iterate, it is inevitable. You can save the time from running the code if you just pre-run it in the command bar and affect the GUI in Studio instead and use that newly affected GUI for the game.