How am I able to create a function similar to require?

Hey everyone, currently I’m working on a project that is trying to make a better functions (don’t ask why lol). Basically the issue I am having is that when I use the function, I can’t do the extension. You know how they have :Fire() or .Load at the end of their require.

local lib = {}

function lib.require(id)
	require(id) -- how do i do the thingy at the end? .load("abayneh12")
end

Help needed, thanks!

1 Like

put the return keyword before require(), then you should be able to use the modules contents outside of the function

1 Like

You can’t, it’s part of Roblox’s API.

Attempt of simplifying require v1:

function require2(target: number | Instance): any
	if type(target) == "number" then
		local InsertService = game:GetService("InsertService")
		target = InsertService:LoadAsset(target):GetChildren()[1]
	elseif typeof(target) ~= "Instance" then
		error("Attempted to call require with invalid argument(s).")
	end
	return require(target)
end

If you can, check my other post. I accidentally created this one.