Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
2

Inquiry on getting scripts from one script?

Asked by
unmiss 337 Moderation Voter
9 years ago

I've seen it before, mainly in APIs that people don't want disclosed. I think it has something to do with require()

For example, I have many scripts in my place that I don't want disclosed. I put them in copylocked models then say require(Id)?

Currently moving on mobile. I looked on the wiki and on questions on SH and don't get it. Is this even possible? Am I even using require correctly?

Please explain if you can. This is involved in giving a place to someone yet I don't want to, well, give the code to them.

I UNDERSTAND THIS HAS BEEN ASKED BEFORE BY SHAWNY. I STILL DO NOT UNDERSTAND MODULESCRIPTS AND REQUIRE, AND HOW THEY LINK TOGETHER.

0
Maybe a better exmple than ImageLabel providded? unmiss 337 — 9y

1 answer

Log in to vote
3
Answered by
Unclear 1776 Moderation Voter
9 years ago

require takes a single argument, which can be one of two things...

  1. A pointer to a ModuleScript ROBLOX object. In other words, a variable that is currently set to some ModuleScript in game.
  2. A numerical ROBLOX asset ID. In other words, the number at the end of a published ROBLOX model's link.

If you choose to use the second option, then require runs the source of that published ROBLOX model. If that model is a ModuleScript, then everything is a-ok and require will return the result of the ModuleScript (note this will always hold true because ModuleScripts must have a return statement at the end of their source).

Indeed, if you want to have a closed-source code, then you just have to toggle the published Model's settings so nobody can take it.

However, please be cautious. Do not depend on this as a complete way to secure your source. If people really want your source they can get it through other means, as there have been exploits for ModuleScript source stealing.

If you want your source to be 100% safe, you cannot publish it anywhere.

Read more about ModuleScripts here.

0
It is being given to a friend. Anywho, couls you provide an example, and also, what type of script would both be in? unmiss 337 — 9y
0
And also, how would I put return at the end of a modulescript? Would I simply just copy the script into a modulescript, put return, then assume it works like it did as a normal script? unmiss 337 — 9y
0
First comment: ModuleScript. No idea why you would use any other script to put the source in, considering this answer was *only* about ModuleScripts... Unclear 1776 — 9y
0
Second comment: Precisely. You have it completely right, though you can specify exactly what you want to return. variable = require(id) will set variable to whatever is returned by the require. Unclear 1776 — 9y
View all comments (2 more)
0
If you want a better explanation on how to set up a ModuleScript for publishing, I suggest re-reading the wiki. Seriously, there is nothing wrong or cryptic about the explanation there. Unclear 1776 — 9y
0
I do not think I am understanding the motive. Nothing is returning, but things are being changed in my script. unmiss 337 — 9y
Ad

Answer this question