Hello! I have been trying to require a module without writing their paths but there are very limited posts about this and none of the solutions worked.
I was wondering, how can you require a module inside of a module script without writing the path?
I am trying to make programs run by another module script called “Run”. Basically when requested it will open the given program and run the module script that operates that program.
Do you think I could try to send a signal to the server via a remote event, and then return the information about the module script by using “return” thing?
Sounds more like you want to require by a dynamic path. Are these “programs” stored in the same location? If so, you could do something like this:
local Programs = game:GetService("ReplicatedStorage")
local function requireByName(Name)
local module = require(Programs[Name])
return module
end
--`require`'s the module `ReplicatedStorage.Program1`
print(requireByPath("Program1"))
The values inside of Shortcuts are objectvalues but are not assigned to anything. The “Program” values inside of the objectvalues are however assigned to their respective program. Running the program works fine. Im attempting to make like the “error” thing that is run by the Run module in case the program is trying to give feedback in case something doesnt go succesfully or it crashes.
local program = {}
local run = game.ReplicatedFirst.Returner.Module:FireServer(113658183973815)
local app
--fired once the program has been opened
function program.run(program)
app = program
--code here.
end
--fires every frame
function program.update()
end
--fires when the program has been terminated or closed
function program.terminate()
--potentially do run.error()
end
return program
Hey, that worked! I didn’t need to require it without the path. Thanks, but if you don’t mind trying… maybe write the code that answers the title of this post so people who come here don’t leave dissapointed?
I’m not sure what you are referring to, this Forum is not for getting people to write code for you. The code I gave was to make my suggestion as clear as possible. You can help other people with the same issue, by marking my most helpful reply as the “Solution”, which adds a link to your original post that other readers with the same issue can see, which takes them to my reply.
Also, your issue was not very clear initially - You need to provide more context to your problem when you ask for help. If you had given the template Program up-front, then I wouldn’t have had to ask any questions and you could have gotten better suggestions from other people.