Is there a way to get the script that required a module

Hi, I need a way to get the script that required the module.

1 Like

No.

Skibidi,Ohio,Rizz,Fanumtax

1 Like

what for? is there a reason you need it. and why cant you just use the script that already required the module

1 Like

You shouldnt need to be doing this. Can you explain what its for?

1 Like

I was going to use it for a library module but then I found a way to retrieve the library from going to my old topics lol sorry guys

1 Like

ModuleScript:

local module = {}

function module.getCallingScript()
	local env = debug.info(2, 's')
	return env
end

return module

LocalScript/Script:

local Replicated = game:GetService('ReplicatedStorage')
local module = require(Replicated.ModuleScript)

print("The calling script is:", module.getCallingScript())
1 Like

This is not true, don’t answer blindly.

1 Like

Yes, it is true. All your code does is self-identify the script that requires the module. He wanted the script that required the module from within, which isn’t possible. Also, I had something to do, so I saved myself time and his, too. Others would’ve asked questions and long explanations for something that never worked… I kept it short and sweet :sunglasses:

1 Like

Short answer: no
Long Answer: No.
Make it a table storing all calling scripts, it’s that easy.

1 Like

@CodeBoomy you should mark this as your solution.

2 Likes

I suppose storing them would work but you still cannot just get the scripts that require the module internally without needing outside intervention (Requiring scripts)

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.