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

how do you make a script builder run local scripts?

Asked by 5 years ago
Edited 5 years ago

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)
0
`loadstring` can't be run on the client; please do some research. http://wiki.roblox.com/index.php?title=Global_namespace/Basic_functions#loadstring TheeDeathCaster 2368 — 5y

1 answer

Log in to vote
0
Answered by
Amiaa16 3227 Moderation Voter Community Moderator
5 years ago

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

0
It is also possible to make your own code compiler, which some admin models have done. mattscy 3725 — 5y
Ad

Answer this question