What even is a PrivateModule? I’ve never heard or seen that before. If you could link me to where I could read up on it, I might be able to explain this for you.
Private modules have suffered a big change recently. Normally you used to be able to upload a ModuleScript named "MainModule" as a model, and it could be ran in any game from a server sided script by using require(asset id of the model).
This was changed recently, now you can only load uncopylocked (free to take) modules using this way. The only non-free to take modules you can load are those owned by the place owner(s).
Other than that, private modules behave like normal ModuleScripts, meaning they can only be required once per session and their return value is cached.
Private modules do not differ from ModuleScripts kept in the DataModel. The only difference is that requiring with an id is restricted to the server and it fetches the ModuleScript from the website, whereas within the DataModel it can be required by both the server and the client (depending on where it’s located in the DataModel) and it exists right there.
To answer your points,
The same thing as a regular ModuleScript. The value will be cached.
Nothing. You’re going to get the same result, because it’s cached.
No you can’t, unless you’re able to get a reference to the ModuleScript instance related to the id. I don’t remember how to do this, it had something to do with getfenv.
No, it doesn’t.
Yes, it can. Any internal web call can fail.
No, you will have to send data yourself manually. LocalScript instances will not be able to see anything about the ModuleScript, nor references it keeps.
I mean, you pretty much have to uncopylock it now to share your module with others. But just because its uncopylocked… doesn’t mean you should just take the code and go creating copies. It’s not really open sourced. It’s forced to be open sourced. So giving credit should still be a priority here. While its okay to copy the code as a version freeze. Do try not to reupload it as your own, unless you did significant changes that really transforms the work into something else. And even then do try to give credit where possible.
Generally though, if you only use a module from well known programmers, or a creator that frequently updates the code. You can try asking them about their process for updates, and if they care to make changes without breaking implementations. This should help you be safe in the long run with not making a copy of the code.
And then in that case you could just use your own unversioned copy of the module.
While I mean you’re really free to do whatever you want with it because of the fact it’s uncopylocked. I do feel we should still keep our morals on subject despite this.
Private Modules that could be require’d by any person don’t exist anymore (they were removed for security reasons), but I will still explain how they did work:
The return value that is required the first time will be returned again (this is normal behavior for ModuleScripts, and is kept here)
The same thing as above.
Private modules loaded by ID were loaded into nil by default, the private module can parent itself but nothing else can. (unless it returns the actual instance itself)
No.
Yes, the same as any other asset. Wrap it in a pcall.
No, the bytecode of a private module is never sent to the client under any circumstances. The descendants can be shared via the method I said above, but there is far easier ways of doing that.
The creators of public module scripts decided to make it open sourced. If they didn’t want the public to get access to it, then they would of kept it within their game file and/ or privately transferred the code to someone they trust for their own game. Which is also why these types of scripts should be called “Public Modules”, considering the new updates, and it’s accessibility.
As I said previously, and as was stated previously. You’re pretty much forced to open source your module if you want to share it with others on the platform because of the changes that happened to Private Modules. And unlike the real industry standard side. Roblox hasn’t really embraced the Open Source / Open Software ideal. With licenses such as GNU Open Source license or Creative Commons.
And just because that’s the case doesn’t mean you shouldn’t add credit. Any who I thought this should be noted as an effort. Not that anyone is going to follow it. But it would still be great if people knew. New programmers have the tendency to copy code wherever they see fit so long as it seems to fit their use case without doing the proper thing such as adding credit or transforming the code.
It’s okay for new programmers to copy publicly sourced code for learning and experimenting. The only time crediting users comes into play is when they plan on releasing a game or some other equivalence (because they are publishing the game as their own)
Going back on topic, if you want to use publicly sourced modules, here is an example:
local module = require(asset id)
--as stated earlier
I’m asking because like I mentioned I want to know how it works so I can use it fully.
I’ll use InsertService instead because I want it to live update.
I am well aware of how to use other people’s Privatemodules.
My opinion on crediting is this;
Nobody shouldn’t have to credit anyone if it’s uncopylocked, if you wanna help people don’t ask for credits, if they wanna include it they will do it on their own, but that’s just my opinion because I don’t care about giving and receiving credits.