Is there any way to check, from what script, is a module being called?

Let’s suppose this is being done ‘locally’, meaning, if the module is being required from multiple scripts and we were to somehow print which script is calling a module, it would print each, how would that be achieved? And, not exactly just print, but, exactly, know the script calling a module. Sorry for me explaining this very badly, here is a example:

local MyModule = {}

function GetRequiring()
    return MyModule.Requiring -- Let's suppose Modules had a .Requiring property, which would return the script requiring the model.
end

return MyModule

From other scripts:

-- Script1
local MyModule = require(.ModuleScript)

print(MyModule().Disabled) -->>> false (.Script1.Disabled)
 --//|\\--
-- Script2
local MyModule = require(.ModuleScript)

print(MyModule:GetRequiring().Name) -->>> Script2 (.Script2.Name)
2 Likes

I found this thread and it is actually very insightful. @Sharksie and @stravant did a phenomenal job in explaining some of the properties of ModuleScripts and why a .Requiring property or any type of method to check for Requiree’s wouldn’t work.

3 Likes