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.
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
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)