Help with autocomplete with null table

  1. What do you want to achieve? Keep it simple and clear!
    I want to use autocomplete in a module table.

  2. What is the issue? Include screenshots / videos if possible!
    Autocomplete not working with table in loader script because it supposed to run the script first and store modules in the table but I want a go around with this.

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I tried to doing return the actul require path but it will took really long to require them in if there too much modules. I also tried to run the game and code while the modules table is loaded but autocomplete not showing. Although the function in the module still work but it just isn’t showing.

Loader Code:

--from Doomforger
local Load = {}

Load.root = game.ReplicatedStorage.Module
Load.Modules = {Packages_Module={}}

function Load:All()
	return Load.Modules.Packages_Module
end

--Load modules to table
for _, Modules_Packages in pairs(Load.root:GetChildren()) do
	if Modules_Packages.ClassName == "Folder" then
		for _, Modules in pairs(Modules_Packages:GetChildren()) do
			if Modules.ClassName == "ModuleScript"then
				local req = require(Modules)
				Load.Modules.Packages_Module[Modules.Name] = req
				print(Load.Modules.Packages_Module)
			end
		end
	end
end

return Load

SampleScript code:

local Sample = {}

function Sample:Print(text:string)
	return print(text)
end

function Sample:Plus(number1,number2)
	return print(number1+number2)
end

return Sample

Using SampleScript Module:

local a = require(game.ReplicatedStorage.Module.Loader)

local b = a.Modules.Packages_Module.SampleScript
b:Print("c") --Does print c

I just want to use autocomplete.

Use metatable and metatable.__index

1 Like

How exactly did you use metatables to allow autocomplete with this module loader? I couldn’t get it to work for me, if you could clarify further I’d really appreciate it. :+1:

The autocomplete doesn’t work even with metatable and metatable.__index or idk how I been trying to making my framework and the autocomplete just doesn’t show up so you can’t, I think

1 Like