President_2000

Sandboxing Code

Dec 2nd, 2020 (edited)
398
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function safeGetChildren(obj)
  2.     local objs = {}
  3.     for _,v in pairs(obj) do
  4.         if not v.Name:match("^^") then
  5.             table.insert(objs, v.Name)
  6.         end
  7.     end
  8.  
  9.     return objs
  10. end
  11.  
  12. function safeClearAllChildren(obj)
  13.     if obj:IsA("Player") or obj:IsA("Players") or obj:IsA("Workspace") or obj:IsA("ServerScriptService") or obj:IsA("Lighting") or obj:IsA("ReplicatedStorage") or obj:IsA("StarterGui") then
  14.         return error("Cannot clear this object!");
  15.     else
  16.         obj:ClearAllChildren();
  17.     end
  18. end
  19.  
  20. function safeRemoveObject(obj)
  21.     local name = obj.Name:lower();
  22.  
  23.     if obj:IsA("Player") or  name == "remoteevents" or obj.Parent == "RemoteEvents" or obj.Parent == "ReplicatedStorage" or obj.Parent == "StarterGui" or obj.Parent == "ServerScriptService" or obj.Parent == "TinySB" then
  24.         return error("Cannot destroy this object!");
  25.     else
  26.         obj:Destroy();
  27.     end
  28. end
  29.  
  30. local Globals = {
  31.     -- Globals
  32.     workspace = workspace,
  33.     print = print,
  34.     error = error,
  35.     table = table,
  36.     pairs = pairs,
  37.     game = game,
  38.     string = string,
  39.     _G = _G,
  40.     getfenv = getfenv,
  41.     loadstring = loadstring,
  42.     ipairs = ipairs,
  43.     next = next,
  44.     os = os,
  45.     pcall = pcall,
  46.     rawequal = rawequal,
  47.     rawget = rawget,
  48.     rawset = rawset,
  49.     select = select,
  50.     setfenv = setfenv,
  51.     setmetatable = setmetatable,
  52.     tonumber = tonumber,
  53.     tostring = tostring,
  54.     type = type,
  55.     unpack = unpack,
  56.     _VERSION = _VERSION,
  57.     xpcall = xpcall,
  58.     collectgarbage = collectgarbage,
  59.     assert = assert,
  60.     gcinfo = gcinfo,
  61.     coroutine = coroutine,
  62.     string = string,
  63.     table = table,
  64.     math = math,
  65.     delay = delay,
  66.     LoadLibrary = LoadLibrary,
  67.     printidentity = printidentity,
  68.     spawn = spawn,
  69.     tick = tick,
  70.     time = time,
  71.     UserSettings = UserSettings,
  72.     Version = Version,
  73.     wait = wait,
  74.     warn = warn,
  75.     ypcall = ypcall,
  76.     PluginManager = PluginManager,
  77.     LoadRobloxLibrary = LoadRobloxLibrary,
  78.     settings = settings,
  79.     stats = stats,
  80.  
  81.     -- Functions
  82.     ["require"] = function(...)
  83.         return error("Cannot require object (API disabled)");
  84.     end,
  85.     ["getchildren"] = function(...)
  86.         return safeGetChildren(...);
  87.     end,
  88.     ['children'] = function(...)
  89.         return safeGetChildren(...);
  90.     end,
  91.     ['clearallchildren'] = function(...)
  92.         return safeClearAllChildren(...);
  93.     end,
  94.     ['destroy'] = function(...)
  95.         return safeRemoveObject(...);
  96.     end,
  97.     ['remove'] = function(...)
  98.         return safeRemoveObject(...);
  99.     end,
  100.     ['kick'] = function(...)
  101.         return safeRemoveObject(...);
  102.     end,
  103.     ['saveplace'] = function(...)
  104.         return error("Cannot save place (API Disabled)");
  105.     end
  106. }
  107. setfenv(1, Globals)
  108. table.foreach(workspace:GetChildren(), print)
RAW Paste Data