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

Can you Instance.new a script?

Asked by
Kitorari 266 Moderation Voter
8 years ago

The title says it all, can you Instance.new a script with all the scripting stuff inside it?

1
As far as I know, you can Instance.new a script, but can't edit what's inside it. I'm not sure though... itsJooJoo 195 — 8y
1
You can make a new script with Instance.new(), however any source code changes you intend to make are not possible. Roblox has RobloxLocked the Source property of all scripts for security. M39a9am3R 3210 — 8y
1
There's always cloning, for this effect. Pyrondon 2089 — 8y
0
Oh okay, thank you everyone <3 Kitorari 266 — 8y
0
Otherwise you could enable game.ServerScriptService.loadStringEnabled and use a StringValue with the standard loadstring() Lua function. Link150 1355 — 8y

1 answer

Log in to vote
2
Answered by 8 years ago

You can Instance.new a script using Instance.new("Script") or Instance.new("LocalScript") however ROBLOX no longer lets us edit a script's .Source property from another normal script (I say normal as things like the CommandBar and plugins can still change script.Source)

You could always do the not so secure somewhat alternative and make a script that runs the the value of a StringValue using loadstring()

local strValue = script.Code
loadstring(strValue.Value)()

Do note that loadstring() is no longer usable from LocalScripts and in order for it to work in normal server scripts ServerScriptService.LoadStringEnabled MUST be set to true.

Ad

Answer this question