Error main.lua:8: attempt to index global 'push' (a boolean value) [duplicate]

Solution 1:

Your menu.lua does not return your table Menu.

So assiging menu = require("menu") result in menu referring to Menu but to true.

From the Lua manual:

Once a loader is found, require calls the loader with a single argument, modname. If the loader returns any value, require assigns the returned value to package.loaded[modname]. If the loader returns no value and has not assigned any value to package.loaded[modname], then require assigns true to this entry. In any case, require returns the final value of package.loaded[modname].

So in line 23 of main.lua you're actually attempting to index true, a boolean value. Menu:load()

Add return Menu to the end of your menu.lua