Creating a script and inserting code

Okay, so I have so far managed to create a script using instance. How do I put code into the newly added script from the main script or is it even possible?

1 Like

You can’t edit the scripts Source using a regular game script, you will have to use a plugin or the command bar.

But could you explain why you want to hardcode in a script’s source?

So it is not possible to create a script using instance and then put things in the script?

Not without a plugin or the command bar, no. But what is this for?

Just trying out some different things for a new project that came to mind, not being able to create a new script and insert code into it is kind of preventing me from going further at the moment. Thanks for your help anyway :slight_smile:

Doing a quick Google-search got me this result, which I think should answer your question:

Short answer: It’s currently impossible to edit the source of a script using a script. But, you could use loadstring() (not recommended)

Edit: The content from that link is 2 years old, though… not sure if things are still applicable. :sweat_smile:

1 Like

That’d be a really cool feature, though.

3 Likes

First of all, welcome to the DevForum! Appears it’s your first post here :slight_smile:

Secondly, while it may be convenient in certain scenario’s, it can also be malicious I think.
Hackers might be able to create, take or edit a script, insert code much easier and deal some real bad damage to your game.

4 Likes

Thanks for the warm welcome! I’m happy to be here. I can’t wait to look for some work in the next few months.

I suppose you’re right; however, I feel like Roblox could definitely mobilize some new security measures to prevent that. Guess we’ll see in the future!

Thanks again for the welcome.

3 Likes