Straightforward question.
ModuleScripts can only return values once to each client and once to the server.
What I have done in the past is send a location to the Module that it can put a StringValue or IntValue into. Then, I would tell the script to wait until a StringValue or IntValue appears:
repeat wait() until script:FindFirstChild("ValueWeAreWaitingFor") ~= nil;
Is there a better way? I notice Quenty's NevermoreEngine has a LoadCustomLibrary function in it. He says that Nevermore Engine caches ModuleScripts. All it seems to do is return a require() of the modules? (I may have just answered my question)
I am 50% sure this is what becomes the LoadCustomLibrary function in other scripts that use it:
local function LoadLibrary(LibraryName)
--- Load's a modular script and packages it as a library.
-- @param LibraryName A string of the resource that ist the LibraryName
-- print(Configuration.PrintHeader .. "Loading Library " .. LibraryName)
local ModularScript = GetResource(LibraryName)
if ModularScript then
if ModularScript:IsA("ModuleScript") then
-- print(Configuration.PrintHeader .. "Loading Library " .. ModularScript:GetFullName())
local LibraryDefinition = require(ModularScript)
--[[if type(LibraryDefinition) == "table" then
-- Import native definitions
for Name, Value in pairs(NativeImports) do
if LibraryDefinition[Name] == nil then
LibraryDefinition[Name] = Value
end
end
--else
--error(Configuration.PrintHeader .. " Library '" .. LibraryName .. "' did not return a table, returned a '" .. type(LibraryDefinition) .. "' value, '" .. tostring(LibraryDefinition) .. "'")
end--]]
return LibraryDefinition
else
error(Configuration.PrintHeader .. " The resource " .. LibraryName
.. " is not a ModularScript, as expected, it is a "
.. ModularScript.ClassName, 2
)
end
else
error(Configuration.PrintHeader .. " Could not identify a library known as '" .. LibraryName .. "'", 2)
end
end
EDIT Specifically what I am looking for a more efficient way to do is: I am making a fun Cribbage game on Roblox, and I wrote a module to find the number of points in the hand. Here is the module, if you really want to see my code. Anyways, I have a localscript that is going to access the module like so:
local CribLib = require(game:GetService("ReplicatedStorage").CribLib)
-- ... ... ... ..
local answers = script:WaitForChild("CardInstructions")
local keepCards = answers:WaitForChild("keepCards")
local tossCards = answers:WaitForChild("tossCards")
local keepCards = game.HttpService:JSONDecode(keepCards.Value)
local tossCards = game.HttpService:JSONDecode(tossCards.Value)
answers:Destroy()
I specifically, was wondering if there is a better method for receiving information from the Module.

2 comments
Can you try to describe what you're trying to accomplish better?
Edited it.