Anyway to figure out how many scripts are requiring a ModulesScript()?

I want to create a script that checks how many scripts are requiring a ModuleScript. Since it seems like something that would be fun to know about since it could help me optimize scripts better in the future. Actually I just want to feel secure that none of my ModuleScripts are hogging up space. It likely won’t happen, but just in case in that 1 in a million chance happens.

Outside of either printing every argument passed to it and trying to control+shift+f for the results in studio, I’m pretty sure there’s no way.

You can always have each ModuleScript adding some sort of value to a globalized table/IntValue every time it is ran.

1 Like

That takes effort, I don’t like effort.

every solution that someone recommends, I recommend you do it you may never if it would solve your problems :wink:

Well it’s a pretty interesting idea he came up with in honestly. I wanted to just quickly make a script, slap some code, wait for some magic to happen and then… delete it.

everything takes effort :man_shrugging: so yeah try to do his solution

Nonono I don’t think you’re getting what I mean. I’m not trying to save how many scripts are requiring the ModuleScript by writing the code. I want to know if there’s a function out there that already did that for me. In the first case, the solution doesn’t work. It’s only getting how many times it’s ran.

No, there is no built-in way, your use case seems too niche to warrant a built-in function anyway. Return a function, increment a counter variable by 1.

local counter = 1

return function()
    counter += 1
    -- do something
end
1 Like

I don’t think you can under normal, legal methods.

1 Like