Formatting a string

I’m making a plugin that packs scripts into a single script.
When trying to replace require, I’ve ran into the following problem: I have no idea how to format strings.
What I’m trying to do is strip the string of the require function and replace the script namespace with my separate dictionary.

I want a require piece of code to go from this:

local Module = require(script.ModuleScript)

To this:

local Module = files.ModuleScript()

How would I perform such conversion?
Thanks.

local str = "local Module = require(script.ModuleScript)"
print(str:gsub("require(script.ModuleScript)", "files.ModuleScript()")

I dont think you can require a module in a diff way, you would still need to use the require.

You see, the game that has these programmable parts has require and loadstring disabled. I’m trying to implement an alternative require function, although I’m unable to convert the strings with “require(script.Somemodule)” to “files.Somemodule()”

Hi :smiley:, does my post above work?

Kind of, although I am attempting to have the “ModuleScript” name changeable, so It could be anything like module,modulescript, script, etc.

Can you give me example of what you’re trying to do?

I want a string like

local mycoolmodule = require(script.verycoolmodule)

to be formatted as

local mycoolmodule = files.verycoolmodule()

So that the local constant name and module object name could be changed