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

How to make a new script instance with a source set from the script?

Asked by
Derzett 51
4 years ago
Edited 4 years ago

So i've been looking all over the internet for this to no avail. So basically i'm trying to make a localscript with a preset source instead of editing it.

I tried multiple methods that didn't work and always gave out the same lacking permission error.

Please if someone has a method on how to do that i beg you tell me how you do it because i really need it right now.

Thanks in advance.

3 answers

Log in to vote
1
Answered by 4 years ago

Hey! I recently dealt with this problem myself, and i got a solution! So what you want to do, from what I can tell, is create a script that has already got the code, so it can happen in game! What I would recommend you do is create the script/localscript in 'ReplicatedStorage', and then access it by referencing it in another script for the part.

For example if you want to create a new part and put the script inside of it you would do

local Script = game.ReplicatedStorage.script:clone()
local part = instance.new("Part")

Script.parent.parent = part

And that would put a copy of the script into the new part!

Ad
Log in to vote
1
Answered by 4 years ago

im not entirely sure but it has to do something with loadasset you can use this to load things like models or something into your studio or game if you want to know more about this go here:

link: https://developer.roblox.com/en-us/api-reference/function/InsertService/LoadAsset

0
with this im guessing you can model a script and load it into your workspace ahsan666666666666 264 — 4y
Log in to vote
1
Answered by
ArtBlart 533 Moderation Voter
4 years ago
Edited 4 years ago

Unfortunately, a script's source can only be indexed via the command bar and plugins. I suppose you could create a local plugin that creates a script and sets the source for you. A tutorial on how to make plugins can be found here.

If you have any further questions, shoot me a DM on Discord, @artblart#3386 and I'd be happy to answer.

Edit: spelling

Answer this question