Advertisement
Descaii

Sandbox

Mar 8th, 2014
272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.84 KB | None | 0 0
  1. local blocked = {Teleport=""}
  2. local real = {}
  3. local fake = {}
  4. function Box(Obj)
  5.     if Obj then
  6.         print("Boxed "..tostring(Obj))
  7.         local a = setmetatable({}, {
  8.             __index = function(a,b)
  9.                 if b == 'Sandbox' then return true end
  10.                 local c = Obj[b]
  11.                 if c and blocked[b]==nil then
  12.                     if type(c) == "userdata" and select(2, pcall(function() return c:IsA"Instance" end)) == true then
  13.                     --  print(tostring(c))
  14.                         return Box(c)
  15.                     elseif type(c) == "function" then
  16.                         return function(...)
  17.                             local vargs = {...}
  18.                             for i = 1, #vargs do
  19.                                 if real[vargs[i]] then
  20.                                     vargs[i] = real[vargs[i]]
  21.                                 end
  22.                             end
  23.                             local n
  24.                             if #vargs > 0 then
  25.                                 n = {Obj[b](unpack(vargs))}
  26.                             else
  27.                                 n = {Obj[b]()}
  28.                             end
  29.                             for i,v in pairs(n) do
  30.                                 if n[i]~=nil then
  31.                                     n[i]=Box(v)
  32.                                 end
  33.                             end
  34.                             return unpack(n)
  35.                         end
  36.                     else
  37.                         return c
  38.                     end
  39.                 else
  40.                     --error('This '..type(c)..' ('..b..') '..'has been disabled.')
  41.                 end
  42.             end,
  43.             __newindex = function(a,b,c)
  44.                 --print(b,"=",c)
  45.                 Obj[b]=c
  46.                 print(tostring(Obj[b]))
  47.             end,
  48.             __tostring = function() return tostring(Obj) end;
  49.         })
  50.         real[a] = Obj
  51.         fake[Obj] = a
  52.         return a
  53.     end
  54. end
  55.  
  56. function Environment(func)
  57.     local oldenv = getfenv()
  58.     local newenv = {}
  59.     setmetatable(newenv,{
  60.         __index = function(a,b)
  61.             if oldenv[b] then
  62.                 if type(oldenv[b]) == 'userdata' then --or type(oldenv[b]) == 'table' then
  63.                     return Box(oldenv[b])
  64.                 --elseif type(oldenv[b]) == 'function' then
  65.                    -- return function(...)
  66.                       --  local ret = {oldenv[b](...)}
  67.                       --  for i = 1, #ret do
  68.                        --     if type(ret[i]) == 'userdata' and select(2, pcall(function() return ret[i]:IsA'Instance' end)) == true then
  69.                           --      ret[i] = Box(ret[i])
  70.                          --   end
  71.                       --  end
  72.                      --   return unpack(ret)
  73.                    -- end;
  74.                 else
  75.                     return oldenv[b]
  76.                 end
  77.             elseif _G[b] then
  78.                 if type(_G[b]) == 'userdata' then--or type(_G[b]) == 'table' then
  79.                     return Box(_G[b])
  80.             --  elseif type(_G[b]) == 'function' then
  81.                     --return function(...)
  82.                         --local ret = {_G[b](...)}
  83.                       --  for i = 1, #ret do
  84.                           --  if type(ret[i]) == 'userdata' and select(2, pcall(function() return ret[i]:IsA'Instance' end)) == true then
  85.                           --      ret[i] = Box(ret[i])
  86.                           --  end
  87.                       --  end
  88.                        -- return unpack(ret)
  89.                    -- end;
  90.                 else
  91.                     return _G[b]
  92.                 end
  93.             end
  94.         end
  95.     })
  96.     setfenv(func,newenv)
  97.     return func()
  98. end
  99.  
  100.  
  101. Environment(loadstring(game:GetService("HttpService"):GetAsync("http://pastebin.com/raw.php?i=wFEbFFWU")))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement