In multiple places, requiring a ModuleScript fails with the error “Error occurred, no output from Lua.”. Here’s the snippet of code where the script errors. The actual error is on the line where the module is required.
local ResourceSettings = Model:FindFirstChild("RESOURCE_SETTINGS");
if ResourceSettings then
print("Proof it exists:", ResourceSettings, typeof(ResourceSettings), ResourceSettings.ClassName);
SettingsData = require(ResourceSettings);
Util.CallIfExists(SettingsData.Middleware, Model); --(Not Relevant)
end
The output then displays;
08:27:12.877 Proof it exists: RESOURCE_SETTINGS Instance ModuleScript - Server - Util:1060
08:27:12.879 Error occurred, no output from Lua. - Studio
For reference, the contents of this module script is;
which is a completely valid modulescript. I’m completely at a loss here since the code was working flawlessly and the error only started an hours ago despite no changes being made.
Yes I have tried to run it in regular roblox AND restart studio, same error both times. Any help would be greatly appreciated. Note this happens in multiple places.
Instead of requiring the script itself, it appears that you are attempting to require a ModuleScript object. The path to the script must be provided as a string when requiring a script, as shown here:
SettingsData = require(ResourceSettings.Source);
You should be able to correctly need the script as a result.
You can use the GetChildren method to retrieve a list of all the children of ResourceSettings, then search for the script among those children if you want to require the script that is inside the ResourceSettings object:
local script = nil
for _, child in pairs(ResourceSettings:GetChildren()) do
if child:IsA("ModuleScript") then
script = child
break
end
end
if script then
SettingsData = require(script)
Util.CallIfExists(SettingsData.Middleware, Model)
else
error("Could not find ModuleScript inside RESOURCE_SETTINGS")
end
I hope this is useful. If you have any queries, please contact me.