With the release of RunContext, I just have some questions regarding OOP.
I have a project where I need server side scripts alongside local scripts in replicated storage or workspace. However, most my server sided logic is in module scripts through OOP.
Since my project is meant to be like a ‘package’ as mentioned in the RunContext post above, I need my module scripts with my server scripts and not in Server Storage.
This raises a few questions though:
Is it safe to have module scripts alongside local scripts?
Does the modules not being required by a local script prevent them from being replicated?
Can the client read my server logic through my modules?
I’d appreciate any explanations, thank you for your time.
RunContext just changes the way that scripts execute (for example, a Script with a Client RunContext can run in ReplicatedStorage or Workspace by default and still function like a LocalScript, whereas legacy LocalScripts can’t run under those services).
TL;DR RunContext doesn’t affect the way that ModuleScripts are replicated, so there’s no point in using it for that purpose
All of the instances themselves will be replicated to the client however the source replicates differently depending on the RunContext and instance type.
ModuleScript - Source always replicates
LocalScript - Source always replicates
Script - Source replicates when RunContext is set to Client
Therefore, any ModuleScript instances you use will have their source accessible to clients. While a bit of a hack you could bypass this by having a server script inside of the ModuleScript that actually sets up the interface but this will mean things such as typechecking won’t be available for that module.
We are aware of this use-case though and there have been some discussions about server only modules. If you have any feedback or use-cases you want to share definitely let me know!