Help with Custom Module, "requested Module experienced an error while loading"

I’ve made Module that works as such

local _ENTRY_FUNCTION = {};
local POTENTIAL_BLOCK_SHOP = _MPOTENTIAL:_FCREATE {
	_PNAME = "BlockShop",
    _BDEFAULT_LOAD = false;
};
POTENTIAL_BLOCK_SHOP:_FLOAD({
	require(script.BlockShop._BLOCK),
	require(script.BlockShop._PURCHASE)
}) function POTENTIAL_BLOCK_SHOP:Load() self:_GET() end

function _ENTRY_FUNCTION:Init()
    POTENTIAL_BLOCK_SHOP:Load();
end

return _ENTRY_FUNCTION ;

In easy terms POTENTIAL_BLOCK_SHOP behaves as class and comes with special function
_FLOAD that takes table of required modulescripts that get Inherited by POTENTIAL_BLOCK_SHOP

Now theres an _ENTRY_FUNCTION:Init() method for the server module loader that calls POTENTIAL_BLOCK_SHOP:Load to run the inherited functions from other modulescripts.

the server module loader

for _,Module in ipairs(script.Parent.Modules:GetChildren()) do
	local ModuleRequired = require(Module)

	if (type(ModuleRequired) == "table") and (type(ModuleRequired["Init"]) == "function") then
		task.spawn(function()ModuleRequired:Init()end)
	end
end

Potential source code

--===<< / VARIABLES \ >>===

--//_POTENTIAL_TYPE_ { _PNAME = {} } -> TYPE
type _POTENTIAL_TYPE_ =  {
	_PNAME : string; 
	_FLOAD : ( 
		_PACKAGES : {}
	) -> boolean; 
	_BDEFAULT_LOAD : boolean
};--//

--//_HPOENTIAL -> CLASS
local _HPOTENTIAL = {

};--//
local _POTENTIALT_HOLDER : {[string]:_POTENTIAL_TYPE_} = {} --//_POTENTIAL_HOLDER -> {}

--===<< / FUNCTIONS \ >>===

--//_FCREATE -> FUNCTION
function _HPOTENTIAL:_FCREATE(_USER_DEFINED_ : _POTENTIAL_TYPE_): _POTENTIAL_TYPE_
	local _USER_POTENTIAL : _POTENTIAL_TYPE_ = {
		_PNAME = _USER_DEFINED_._PNAME,
		_BDEFAULT_LOAD = _USER_DEFINED_._BDEFAULT_LOAD
	}  :: _POTENTIAL_TYPE_ or error(`{script.Parent} - Couldn't Create {_USER_DEFINED_._PNAME}`)
	function _USER_POTENTIAL:_FLOAD(_PACKAGES : {}): boolean
		if (typeof(_PACKAGES) == 'table' and _PACKAGES ~= nil) then
			for _, _MSCRIPTS in ipairs(_PACKAGES) do task.wait()
				if (_MSCRIPTS:IsA("ModuleScript")) then
					setmetatable(_USER_POTENTIAL, require(_MSCRIPTS));
				end
			end
			if (_USER_POTENTIAL._BDEFAULT_LOAD) then
				for _, _DEFAULT_PACKAGES in ipairs(script:GetChildren()) do task.wait()
					if (_DEFAULT_PACKAGES:IsA("ModuleScript")) then setmetatable(_USER_POTENTIAL, require(_DEFAULT_PACKAGES))  end
				end
			end
		else 
			error(`{script.Parent} - {_PACKAGES}`) 
			return false
		end
	end
	return _USER_POTENTIAL
end

return _HPOTENTIAL

--//POTENTIAL

I dont know what’s the problem Ive tried everything And posting this Issue on DevForum Is last resort for me

3 Likes

I don’t see POTENTIAL_BLOCK_SHOP:Get() defined anywhere

1 Like

That’s one of the functions from the inherited modules