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

How to change code in a script from another script?

Asked by 6 years ago

So, i was wanting to know like i have a script and it has code in it, but how do i change the code in that script with another one? I don't really know how else to explain.

0
Why is everyone making a script builder now? hiimgoodpack 2009 — 6y
0
Your answer is : YOU DON'T OK???? Unless you have lvl 5 or lvl 6 script. hiimgoodpack 2009 — 6y
0
There is ABSOLUTELY no need to do this. If you need to dynamically create and run code(command line GUI), Enable LoadString but this puts you at a huge security risk lukeb50 631 — 6y
0
But that doesnt change the code in a script. It just changes what it does. hiimgoodpack 2009 — 6y
View all comments (3 more)
0
Thats not what i asked KinqAustinn 293 — 6y
0
Well thats your only option lukeb50 631 — 6y
0
You could put a StringValue as the child of one script and loadstring that StringValue with the original script, and make modifications with the StringValue in a second script. It's very inefficient though you'd be better off using BindableEvents User#9949 0 — 6y

2 answers

Log in to vote
0
Answered by 6 years ago

Short answer - you can't. The script needs to have the permission level of a plugin or higher to change the source of a script.

But, you can accomplish roughly the same thing with loadstring() (this is assuming you are wanting to make a script builder - note to those in the comments, maybe you should ask what they are trying to do first?)

Here's an example:

-->> Trys to execute what someone says as code every time they speak

Player.Chatted:Connect(function(Message)
    loadstring(Message)
end)

Make sure loadstring is enabled, or it won't work.


Hope I helped!

~TDP

0
How do i enable loadstring? KinqAustinn 293 — 6y
0
How do i enable loadstring? KinqAustinn 293 — 6y
0
LoadString is under ServerScriptStorage. Before you do this tho, remember that LoadString makes ANYTHING possible with even a basic hack, and there is no way to stop that. Your game will most likely never go ANYWHERE with LoadString. Find other ways to do what you want to do with things such as if statements. lukeb50 631 — 6y
Ad
Log in to vote
0
Answered by 6 years ago

Well, what I would do is keep a script in Lighting or ServerStorage and clone it fo when you need it.

EX;

script.Parent.TouchEnded:connect(function()

local a = game.Lighting:findFirstChild("Script name"):Clone()
    a.Parent = game.Workspace:findFirstChild("Insert Model Here")

end)

Or you could simply just have a script disabled and enable it when something happens

EX;

script.Parent.TouchEnded:connect(function()

game.Workspace.[insert model].[script name].Enabled = true

end)

Answer this question