How can I make a "Directory" system for tables

I am trying to make a “directory” system for a table. I have seen it done before but I do not know how to do it myself or how it works. In short, I am trying to achieve something like this:

local Values = {}
function NewButton(Section, Called, Txt)
	local factor = 8
	local TextButton = Create("TextButton", {
		BackgroundTransparency = 1,
		Name = Called,
		Parent = Section,
		Size = UDim2.new(0, factor, 0, factor),
		Visible = true,
		ZIndex = 1,
		Text = Txt
	})
    -- I have this
      local SubArray = {"NewButton", Section, Called, TextButton}
      table.insert(Values, SubArray)  
end

NewButton(ScreenGui, "Example button", "Click me")

-- What I am trying to do
print(Values["NewButton"][ScreenGui]["Example button"].Text)
 -- I want the above line to print the Text on the TextButton that NewButton created

I considered doing something like this:

for i, v in pairs(Values) do
	if v[1] == "NewButtom" then
		if v[2] == ScreenGui then
			if v[3] == "Example Button" then
				print(v[4].Text)
			end
		end
	end 
end

But I am worried that this will be unusable for large tables as it will be very slow as the function iterates over the large table.

I am looking for an answer that goes somewhat like this:

local Values = {}
function NewButton(Section, Called, Txt)
	local factor = 8
	local TextButton = Create("TextButton", {
		BackgroundTransparency = 1,
		Name = Called,
		Parent = Section,
		Size = UDim2.new(0, factor, 0, factor),
		Visible = true,
		ZIndex = 1,
		Text = Txt
	})
     -- Table stuff here to make print(Values["NewButton"][ScreenGui]["Example button"].Text) return Txt
end

NewButton(ScreenGui, "Example button", "Click me")

print(Values["NewButton"][ScreenGui]["Example button"].Text) -- "Click me"

Not quite sure what you’re trying to do exactly. Are you just wanting to store the TextButton instance that NewButton creates and print it’s text? If so have NewButton return(TextButton) and try something like this:

Values["Example"] = NewButton(ScreenGui, "Example Button", "Click Me")
print(Values["Example"].Text)

This will work for me, thanks.