Hence the title, I would like to know how to edit a script in-game… By possibly using another script. The scripting inside of it isn’t a property, so I’m not sure if it’s possible.
If it is, though, please let me know in a post!
Hence the title, I would like to know how to edit a script in-game… By possibly using another script. The scripting inside of it isn’t a property, so I’m not sure if it’s possible.
If it is, though, please let me know in a post!
It is not possible, unless you’re creating a plugin.
There are probably better ways to do whatever you’re trying to accomplish, though.
To get the text/script that is inside a script you could use:
Script.Source
But i think this is only possible thru a plugin or with a the Command Bar in studio. So with a other script you wil have to test.
A script’s Source
property isn’t accessible except through plugin code or the command bar, IOW it can’t be modified in-game. If you want to create, edit, and run lua code at run-time you could use the loadstring
function.
A lot of you are mentioning plugins, and believe it or not… That’s why I wanted to know how to do it. I’m trying to make one where you can insert parts with scripts already inside them. If you can, please further explain how to do this!
Ok, if you are making a plugin then a script’s Source can be set to a string like any normal property.
Example:
local part = Instance.new("Part")
part.Name = "SpawnedPart"
part.Parent = workspace
local newScript = Instance.new("Script")
newScript.Source = [[
print("This script was created inside "..script.Parent:GetFullName().."!")
]]
newScript.Parent = part