How to make a script inside a script

I’m having trouble trying to make a script inside of a script (making a code in a script using another script)
I don’t know how to do this can someone help?

3 Likes

Do you mean “I want to run a string as code”, or “I want to Instance.new a script and change what it contains when you open it”?

2 Likes

I believe creating scripts what create scripts inside other scripts isn’t possible. It would be pretty useless in my opinion.

If I understood correctly, you’re trying to tell a script via a different script to change all or some of it’s values inside of it.

1 Like

You can’t create scripts with code inside of them unless you’re making a plugin.

1 Like

You can definitely share variables between scripts. There’s a thing called “Global variables.” Local variables are basically variables only inside that one script. Global variables can be used between all the scripts I believe.

So… you may put that in work if you’d like to do that.

2 Likes

You can have multiple scripts in and object.

1 Like

Only plugin scripts and code ran through the command bar (or identities higher than or of those) can read and write to script.Source.

1 Like

You can’t change a script’s source without a plugin, or the command bar, therefore, you can’t make scripts with another script, not used for a plugin.

1 Like

Your best bet would be loadstring honestly.

1 Like

Aren’t loadstrings the sketchiest things in the world?
Weren’t they causing like more chances for exploiters to exploit?

Not unless your system is designed for it to become dangerous, It isn’t inherently bad - simply enabling the property and using it on the server is not dangerous.

2 Likes

no

If the server is not allowing clients to execute code through a remote you’re fine. Anyone that says enabling it alone is dangerous is misinformed or is just riding the “loadstring bad!!” bandwagon

2 Likes

Anything can be bad if you make it unsafe.

how would i do this exactly? may I have some pointers?

Since you already know what the code is, just do

loadstring("print(1)")() -- this code is just an example
1 Like

Loadstrings are only limited to the server

2 Likes

OP never said if they were using a local script or not, if this ends up being the case then oh well, or make a custom loadstring (more complex, although the only custom one i know is adonis’, so you could take a look at that)

1 Like

alright thanks for helping me.

1 Like