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
script.Parent.TextButton.MouseButton1Down:connect(function()
local codetoexecute = script.Parent.TextBox.Text
local scripttable = {}
local function runInSandbox(f)
--get the old function environment
local oldenv = getfenv(f)
--create a new one
local newenv = setmetatable({}, {
__index = function(_, k)
if k:lower() == 'game' or k:lower() == 'workspace' or k == 'Instance' then
--that prevents any instances being accessed
return nil
else
--but otherwise defaults to the old one
return oldenv[k]
end
end
})
--call the function in its new environment
setfenv(f, newenv)
f()
end
local func,err = loadstring(codetoexecute)()
table.insert(scripttable,codetoexecute)
end)

1 comment
loadstringcan't be run on the client; please do some research. http://wiki.roblox.com/index.php?title=Global_namespace/Basic_functions#loadstring