i have been wanting help on this for a long time im trying to create a script builder and cant seem to know how i can make it on my game so it can run local scripts --My Attempt
01 | script.Parent.TextButton.MouseButton 1 Down:connect( function () |
02 | local codetoexecute = script.Parent.TextBox.Text |
03 | local scripttable = { } |
04 | local function runInSandbox(f) |
05 | --get the old function environment |
06 | local oldenv = getfenv (f) |
07 |
08 | --create a new one |
09 | local newenv = setmetatable ( { } , { |
10 | __index = function (_, k) |
11 | if k:lower() = = 'game' or k:lower() = = 'workspace' or k = = 'Instance' then |
12 | --that prevents any instances being accessed |
13 | return nil |
14 | else |
15 | --but otherwise defaults to the old one |
You cannot use loadstring()
in LocalScripts.
What script builders do is they make an api on own web hosts which uploads a LocalScript with the specified source as a model to roblox using a dummy account, and then returns the model id which can be used with LoadAsset()
or require()
(if they make it a ModuleScript
with a LocalScript
parented to it).