Table.find not finding value in table

I am trying to use table.find to find a GUID value in an array of tables. Below I paste the code and a screenshot of the print results.

function InventoryService:FindItemByGUID(myTable, GUID)

    local resuts = table.find(myTable, GUID)

    print("GUID to find: ", GUID)
    print("table to find in: ", myTable)
    print("results of table.find", results)

end

here is a screenshot of the resulting prints, you can see the GUID is in fact stored in one of the tables.

What i need is to get the array index of the table that has this GUID in. I can of course use a more iterative approach but I thought i would give table.find for the first time.

Thanks!

1 Like

You would have to loop through each table and get the GUID index.
table.find only works for arrays, not dictionaries

3 Likes

table.find only looks for values in the passed array, if this array has another array as a value table.find won’t pick this up.

An example of how to use table.find is:

local myArray = {
    “Value”;
    “Value2”;
    {
        “Hello”;
    }
}

local index = table.find(myArray[3], “Hello”)
3 Likes

I understand now, thanks to all for helping!

1 Like