How do I make a table search the __index of its __index?

Say I have a table with its metatable having a metatable within it:

["speed"]: 40,
["__index"]:
   ["name"]: "ball",
   ["__index"]:
      ["this"]: "it doesn't know this exists"

How can I make it such that I can find “this” all the way from the original table? It doesn’t seem to be working

1 Like

probably try changing the name of the second __index

Something like this?

local a = setmetatable({
	speed = 40
}, {
	__index = setmetatable({
		name = "ball"
	},
	{
		__index = {
			this = "it does know this exists"
		}
	})
})

print(a.this)

you need to set metatable, not insert another table

local t = {
    Orange = 5
}
t.__index = t

local mt1 = {
    Lemon = 5
}
mt1.__index = t

local mt2 = {
    Apple = 3
}
mt2.__index = mt1