Advertisement
DrawingJhon

New FE Compatibility

Oct 30th, 2020 (edited)
402
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local wrap, unwrap
  2.  
  3. do
  4. local game = game
  5. local workspace, Workspace = workspace, Workspace
  6. local owner = owner
  7. local Instance = Instance
  8. local wrappercache = setmetatable({}, {__mode = "k"})
  9. local customProperties = {}
  10. script.Parent = owner:findFirstChildOfClass("PlayerGui")
  11.  
  12. local function isInstance(obj)
  13.     return pcall(game.IsA, obj, "Instance")
  14. end
  15. local function eject(obj, functionName)
  16.     if not isInstance(obj) then error("Expected ':' not '.' calling member function "..functionName) end
  17. end
  18.  
  19. wrap = function(real)
  20.     --[[for w,r in next,wrappercache do
  21.         if r == real then
  22.             return w
  23.         end
  24.     end]]
  25.     do
  26.         local wrapped = table.find(wrappercache, real)
  27.         if wrapped then
  28.             return wrapped
  29.         end
  30.     end
  31.     if type(real) == "userdata" then
  32.         local fake = newproxy(true)
  33.         local meta = getmetatable(fake)
  34.         meta.__index = function(s,k)
  35.             local class, index = typeof(real) == "Instance" and real.ClassName or "", type(k) == "string" and k or ""
  36.             local customValue = (customProperties["onread:"..class..":"..index] or customProperties["onread:Instance:"..index]);
  37.             local onIndex = customProperties["onindex:"..class] or customProperties["onindex:Instance"] or customProperties["onindex:"..class..":"..index] or customProperties["onindex:Instance:"..index]
  38.             if customValue and typeof(real) == "Instance" then
  39.                 return wrap(customValue)
  40.             elseif onIndex and typeof(real) == "Instance" then
  41.                 return wrap(onIndex(real, index))
  42.             end
  43.             if typeof(real) == "RBXScriptSignal" then
  44.                 if k == "Connect" or k == "connect" then
  45.                     local conn = real[k]
  46.                     return function(...)
  47.                         local hr = {...}
  48.                         local self = hr[1]
  49.                         local func = hr[2]
  50.                         if self ~= s then
  51.                             return wrap(conn(...))
  52.                         end
  53.                         return conn(real, function(...)
  54.                             local args = wrap{...}
  55.                             func(unpack(args))
  56.                         end)
  57.                     end
  58.                 end
  59.             end
  60.             return wrap(real[k])
  61.         end
  62.         meta.__newindex = function(s,k,v)
  63.             local class, index = typeof(real) == "Instance" and real.ClassName or "", type(k) == "string" and k or ""
  64.             local onEdit = (customProperties["onedit:"..class..":"..index] or customProperties["onedit:Instance:"..index]);
  65.             local onNewIndex = customProperties["onedit:"..class] or customProperties["onedit:Instance"]
  66.             if type(v) == "function" then
  67.                 local func = function(...)
  68.                     local args = wrap{...}
  69.                     local returns =  unwrap{v(unpack(args))}
  70.                     return unpack(returns)
  71.                 end
  72.                 if onNewIndex then
  73.                     onNewIndex(real, k, func)
  74.                 elseif onEdit then
  75.                     onEdit(real, func)
  76.                 else
  77.                     real[k] = func
  78.                 end
  79.             else
  80.                 if onNewIndex then
  81.                     onNewIndex(real, k, unwrap(v))
  82.                 elseif onEdit then
  83.                     onEdit(real, unwrap(v))
  84.                 else
  85.                     real[k] = unwrap(v)
  86.                 end
  87.             end
  88.         end
  89.         meta.__call = function(self, ...)
  90.             local args = unwrap{...}
  91.             local results = wrap{real(unpack(args))}
  92.             return unpack(results)
  93.         end
  94.         meta.__tostring = function(s)
  95.             return tostring(real)
  96.         end
  97.         meta.__concat = function(v1, v2)
  98.             return wrap(real .. unwrap(v2));
  99.         end
  100.         meta.__add = function(v1, v2)
  101.             return wrap(real + unwrap(v2));
  102.         end
  103.         meta.__sub = function(v1, v2)
  104.             return wrap(real - unwrap(v2));
  105.         end
  106.         meta.__mul = function(v1, v2)
  107.             return wrap(real * unwrap(v2));
  108.         end
  109.         meta.__div = function(v1, v2)
  110.             return wrap(real / unwrap(v2));
  111.         end
  112.         meta.__mod = function(v1, v2)
  113.             return wrap(real % unwrap(v2));
  114.         end
  115.         meta.__pow = function(v1, v2)
  116.             return wrap(real ^ unwrap(v2));
  117.         end
  118.         meta.__unm = function()
  119.             return wrap(-real)
  120.         end
  121.         meta.__eq = function(v1, v2)
  122.             return wrap(real == unwrap(v2));
  123.         end
  124.         meta.__lt = function(v1, v2)
  125.             return wrap(real < unwrap(v2));
  126.         end
  127.         meta.__le = function(v1, v2)
  128.             return wrap(real <= unwrap(v2));
  129.         end
  130.         meta.__len = function()
  131.             return wrap(#real);
  132.         end
  133.         wrappercache[fake] = real
  134.         return fake
  135.     elseif type(real) == "function" then
  136.         local fake = function(...)
  137.             local args = unwrap{...}
  138.             local results = wrap{real(unpack(args))}
  139.             return unpack(results)
  140.         end
  141.         wrappercache[fake] = real
  142.         return fake
  143.     elseif type(real) == "table" then
  144.         local fake = {}
  145.         for k,v in next,real do
  146.             fake[k] = wrap(v)
  147.         end
  148.         if getmetatable(real) ~= nil then
  149.             local mt = {}
  150.             mt.__call = function(s, ...)
  151.                 local args = unwrap{...}
  152.                 local results = wrap{real(unpack(args))}
  153.                 return unpack(results)
  154.             end
  155.             mt.__tostring = function()
  156.                 return tostring(real)
  157.             end
  158.             mt.__index = function(s, k)
  159.                 return wrap(real[k])
  160.             end
  161.             mt.__newindex = function(s, k, v)
  162.                 real[k] = unwrap(v)
  163.             end
  164.             mt.__metatable = getmetatable(real)
  165.             mt.__concat = function(v1, v2)
  166.                 return wrap(real .. unwrap(v2))
  167.             end
  168.             mt.__add = function(v1, v2)
  169.                 return wrap(real + unwrap(v2))
  170.             end
  171.             mt.__sub = function(v1, v2)
  172.                 return wrap(real - unwrap(v2))
  173.             end
  174.             mt.__mul = function(v1, v2)
  175.                 return wrap(real * unwrap(v2))
  176.             end
  177.             mt.__div = function(v1, v2)
  178.                 return wrap(real / unwrap(v2))
  179.             end
  180.             mt.__mod = function(v1, v2)
  181.                 return wrap(real % unwrap(v2))
  182.             end
  183.             mt.__pow = function(v1, v2)
  184.                 return wrap(real ^ unwrap(v2))
  185.             end
  186.             mt.__unm = function()
  187.                 return wrap(-real)
  188.             end
  189.             mt.__eq = function(v1, v2)
  190.                 return wrap(real == unwrap(v2))
  191.             end
  192.             mt.__lt = function(v1, v2)
  193.                 return wrap(real < unwrap(v2))
  194.             end
  195.             mt.__le = function(v1, v2)
  196.                 return wrap(real <= unwrap(v2))
  197.             end
  198.             mt.__len = function()
  199.                 return wrap(#real)
  200.             end
  201.             setmetatable(fake, mt)
  202.         end
  203.         wrappercache[fake] = real
  204.         return fake
  205.     end
  206.     return real
  207. end
  208.    
  209. unwrap = function(wrapped)
  210.     if type(wrapped) == "table" then
  211.         local real = {}
  212.         for k,v in next,wrapped do
  213.             real[k] = unwrap(v)
  214.         end
  215.         return real
  216.     else
  217.         local real = wrappercache[wrapped]
  218.         if real == nil then
  219.             return wrapped
  220.         end
  221.         return real
  222.     end
  223. end
  224.  
  225. local LocalScript = NLS([==[local Event = script:WaitForChild("Remote")
  226. local ahh = script:waitForChild'GetClientProperty'
  227. local Mouse = owner:GetMouse()
  228. local UIS = game:GetService("UserInputService")
  229. local cam = workspace.CurrentCamera
  230. local mData = {'KeyDown','KeyUp','Button1Down','Button1Up','Button2Down','Button2Up'}
  231. local cData = {CFrame=nil,CoordinateFrame=nil,CameraSubject=nil,CameraType=nil,FieldOfView=nil,Focus=nil,HeadLocked=nil,HeadScale=nil,ViewportSize=nil}
  232. local onMouse = function(int, type)
  233.     Mouse[type]:connect(function(...)
  234.         Event:FireServer({Type='Mouse',Event=type:lower(),Args={...}})
  235.     end)
  236. end
  237. table.foreach(mData, onMouse)
  238. local input = function(type)
  239.     UIS[type]:connect(function(io,RobloxHandled)
  240.         if RobloxHandled then return end
  241.         Event:FireServer({Type='UserInput',Event=type:lower(),Args={{KeyCode=io.KeyCode,UserInputType=io.UserInputType,UserInputState=io.UserInputState}, false}})
  242.     end)
  243. end
  244. input('InputBegan') input('InputChanged') input('InputEnded')
  245. UIS.TextBoxFocusReleased:connect(function(inst)
  246.     Event:FireServer{Type='TextboxReplication',TextBox=inst,Text=inst.Text}
  247. end)
  248. Event.OnClientEvent:Connect(function(action, data)
  249.     if action == "newindex" then
  250.         local obj = data.Instance
  251.         if obj == "Camera" then
  252.             cam[data.Index] = data.NewIndex
  253.         else
  254.             obj[data.Index] = data.NewIndex
  255.         end
  256.     end
  257. end)
  258. local h,t,x,y
  259. local HB = game:GetService("RunService").Heartbeat
  260. ahh.OnClientInvoke = function(wht, obj, int)
  261.     if wht == 'Ready' then
  262.         return true
  263.     elseif wht == 'GetProperty' then
  264.         return obj[int]
  265.     end
  266. end
  267. while true do
  268.     if h~=Mouse.Hit or t~=Mouse.Target or x~=Mouse.X or y~=Mouse.Y then
  269.         h,t=Mouse.Hit,Mouse.Target
  270.         Event:FireServer({Type='Mouse',Variables={Hit=h,Target=t,X=x,Y=y}})
  271.     end
  272.     local changed = false
  273.     local sentCam = {}
  274.     for prop, value in pairs(cData) do
  275.         if cam[prop] ~= value then
  276.             sentCam[prop] = cam[prop]
  277.             changed = true
  278.         end
  279.         cData[prop] = cam[prop]
  280.     end
  281.     if changed then
  282.         Event:FireServer({Type='Camera',Variables=sentCam})
  283.     end
  284.     for i=1,2 do
  285.         HB:Wait()
  286.     end
  287. end]==], owner.PlayerGui)
  288.  
  289. local Bindable = Instance.new("BindableEvent")
  290. local remote = Instance.new("RemoteEvent")
  291. remote.Name = "Remote"
  292. local GetProperty = Instance.new("RemoteFunction")
  293. GetProperty.Name = "GetClientProperty"
  294. GetProperty.Parent = LocalScript
  295. remote.Parent = LocalScript
  296. local Sounds = setmetatable({}, {__mode = "k"})
  297. local FakeCam = {
  298.     ["CFrame"] = CFrame.new();
  299.     ["CoordinateFrame"] = CFrame.new();
  300. }
  301.  
  302. local FakeMouse = {
  303.     ["Hit"] = CFrame.new();
  304.     ["Target"] = nil;
  305.     ["X"] = 0;
  306.     ["Y"] = 0;
  307. }
  308.  
  309. remote.OnServerEvent:Connect(function(plr, data)
  310.     if plr ~= owner then return end
  311.     if data.Type == "Camera" then
  312.         for i, v in next, data.Variables do
  313.             FakeCam[i] = v
  314.         end
  315.     elseif data.Type == "Mouse" and data.Variables then
  316.         for i, v in next, data.Variables do
  317.             FakeMouse[i] = v
  318.         end
  319.     elseif data.Type == "TextboxReplication" then
  320.         local tb = data.TextBox
  321.         if not tb then return end
  322.         local text = data.Text
  323.         tb.Text = text
  324.         Bindable:Fire{Type = "TextBox", Event = "FocusLost", Args = {tb}}
  325.     end
  326. end)
  327. local function RegSound(sound)
  328.     if not sound:IsA("Sound") then return end
  329.     game:GetService("RunService").Heartbeat:Connect(function()
  330.         if sound.Parent then
  331.             local pl = GetProperty:InvokeClient(owner, sound.Parent and "GetProperty" or "Ready", sound, "PlaybackLoudness")
  332.             if pl then
  333.                 Sounds[sound] = pl
  334.             end
  335.         end
  336.     end)
  337. end
  338. for i, v in pairs(workspace:GetDescendants()) do
  339.     RegSound(v)
  340. end
  341. workspace.DescendantAdded:Connect(RegSound)
  342.  
  343. customProperties = {
  344.     ["onread:Players:LocalPlayer,localPlayer"] = owner,
  345.     ["onread:RunService:RenderStepped"] = game:GetService("RunService").Heartbeat,
  346.     ["onread:Player:GetMouse,getMouse"] = function(plr)
  347.         eject(plr, "GetMouse")
  348.         if plr ~= owner then return end
  349.         local fake = newproxy(true)
  350.         local mt = getmetatable(fake)
  351.  
  352.         mt.__index = function(self, index)
  353.             if FakeMouse[index] then
  354.                 return FakeMouse[index]
  355.             elseif index == "x" then
  356.                 return FakeMouse.X
  357.             elseif index == "y" then
  358.                 return FakeMouse.Y
  359.             end
  360.             local ValidConns = {"KeyDown", "keyDown", "KeyUp", "keyUp", "Button1Down", "button1Down",
  361.             "Button1Up", "button1Up", "Button2Down", "button2Down", "Button2Up", "button2Up", "HitMoved",
  362.             "hitMoved"}
  363.             local function OnEvent(type)
  364.                 local ud = newproxy(true)
  365.                 local meta = getmetatable(ud)
  366.                 meta.__index = function(self, index)
  367.                     if index == "Connect" or index == "connect" then
  368.                         return function(self, func)
  369.                             if self ~= ud then
  370.                                 error("Invalid argument #1 to 'Connect' (RBXScriptSignal expected, got "..tostring(self)..")")
  371.                             end
  372.                             return remote.OnServerEvent:Connect(function(plr, data)
  373.                                 if plr ~= owner or data.Type ~= "Mouse" then return end
  374.                                 if data.Event == type:lower() then
  375.                                     local args = data.Args
  376.                                     local results = wrap{unpack(args)}
  377.                                     func(unpack(results))
  378.                                 end
  379.                             end)
  380.                         end
  381.                     elseif index == "Wait" or index == "wait" then
  382.                         return function(self)
  383.                             if self ~= ud then
  384.                                 error("Invalid argument #1 to 'Connect' (RBXScriptSignal expected, got "..tostring(self)..")")
  385.                             end
  386.                             local result
  387.                             repeat
  388.                                 local plr, data = remote.OnServerEvent:Wait()
  389.                                 if plr == owner and data.Type == "Mouse" then
  390.                                     if data.Event == type:lower() then
  391.                                         result = data.Args
  392.                                     end
  393.                                 end
  394.                             until result
  395.                             return unpack(result)
  396.                         end
  397.                     end
  398.                     error(index.." is not valid member of RBXScriptSignal")
  399.                 end
  400.                 meta.__newindex = function(self, k, v)
  401.                     error(k..' is not valid member of PlayerMouse "Instance"')
  402.                 end
  403.                 meta.__tostring = function(self)
  404.                     return "Signal "..type
  405.                 end
  406.                 meta.__metatable = "The metatable is locked"
  407.                 meta.__call = function(self)
  408.                     error("attempt to call a RBXScriptSignal value")
  409.                 end
  410.                 return ud
  411.             end
  412.             if table.find(ValidConns, index) then
  413.                 return OnEvent(index)
  414.             end
  415.             error(index..' is not valid member of PlayerMouse "Instance"')
  416.         end
  417.         mt.__newindex = function(self, k, v)
  418.             error(k..' is not valid member of PlayerMouse "Instance"')
  419.         end
  420.         mt.__metatable = "The metatable is locked"
  421.         mt.__tostring = function(self)
  422.             return "Instance"
  423.         end
  424.         mt.__call = function(self)
  425.             error("attempt to call a "..tostring(self).." value")
  426.         end
  427.         return fake
  428.     end,
  429.     ["onindex:UserInputService"] = function(obj, index)
  430.         local ValidConns = {"InputChanged", "inputChanged", "InputBegan", "inputBegan", "InputEnded",
  431.         "inputEnded"}
  432.         local function OnEvent(type)
  433.             local ud = newproxy(true)
  434.             local meta = getmetatable(ud)
  435.             meta.__index = function(self, index)
  436.                 if index == "Connect" or index == "connect" then
  437.                     return function(self, func)
  438.                         if self ~= ud then
  439.                             error("Invalid argument #1 to 'Connect' (RBXScriptSignal expected, got "..tostring(self)..")")
  440.                         end
  441.                         return remote.OnServerEvent:Connect(function(plr, data)
  442.                             if plr ~= owner or data.Type ~= "UserInput" then return end
  443.                             if data.Event == type:lower() then
  444.                                 local args = data.Args
  445.                                 local results = wrap{unpack(args)}
  446.                                 func(unpack(results))
  447.                             end
  448.                         end)
  449.                     end
  450.                 elseif index == "Wait" or index == "wait" then
  451.                     return function(self)
  452.                         if self ~= ud then
  453.                             error("Invalid argument #1 to 'Connect' (RBXScriptSignal expected, got "..tostring(self)..")")
  454.                         end
  455.                         local result
  456.                         repeat
  457.                             local plr, data = remote.OnServerEvent:Wait()
  458.                             if plr == owner then
  459.                                 if data.Event == type:lower() then
  460.                                     result = data.Args
  461.                                 end
  462.                             end
  463.                         until result
  464.                         return unpack(result)
  465.                     end
  466.                 end
  467.                 error(index.." is not valid member of RBXScriptSignal")
  468.             end
  469.             meta.__newindex = function(self, k, v)
  470.                 error(k..' cannot be assigned to')
  471.             end
  472.             meta.__tostring = function(self)
  473.                 return "Signal "..type
  474.             end
  475.             meta.__metatable = "The metatable is locked"
  476.             meta.__call = function(self)
  477.                 error("attempt to call a "..tostring(self).." value")
  478.             end
  479.             return ud
  480.         end
  481.         if table.find(ValidConns, index) then
  482.             return OnEvent(index)
  483.         end
  484.         error(index..' is not valid member of UserInputService "Instance"')        
  485.     end,
  486.     ["onindex:Camera"] = function(obj, index)
  487.         local prop = obj[index]
  488.         return FakeCam[index] or prop
  489.     end,
  490.     ["onedit:Camera"] = function(obj, i, v)
  491.         local bruh = obj[i]
  492.         if obj == workspace.CurrentCamera then
  493.             remote:FireClient(owner, "newindex", {Instance = "Camera", Index = i, NewIndex = v})
  494.         else
  495.             remote:FireClient(owner, "newindex", {Instance = obj, Index = i, NewIndex = v})
  496.         end
  497.     end,
  498.     ["onindex:Sound:PlaybackLoudness"] = function(obj, index)
  499.         local result = Sounds[obj]
  500.         return result or obj[index]
  501.     end,
  502.     ["onindex:TextBox:FocusLost,focusLost"] = function(obj, index)
  503.         local ud = newproxy(true)
  504.         local meta = getmetatable(ud)
  505.         meta.__index = function(self, index)
  506.             if index == "Connect" or index == "connect" then
  507.                 return function(self, func)
  508.                     if self ~= ud then
  509.                         error("Invalid argument #1 to 'Connect' (RBXScriptSignal expected, got "..tostring(self)..")")
  510.                     end
  511.                     return Bindable.Event:Connect(function(data)
  512.                         if data.Type ~= "TextBox" then return end
  513.                         if data.Event == "FocusLost" then
  514.                             local tb = data.Args[1]
  515.                             if tb == obj then
  516.                                 local args = data.Args
  517.                                 local results = wrap{unpack(args)}
  518.                                 func(unpack(results))
  519.                             end
  520.                         end
  521.                     end)
  522.                 end
  523.             elseif index == "Wait" or index == "wait" then
  524.                 return function(self)
  525.                     if self ~= ud then
  526.                         error("Invalid argument #1 to 'Connect' (RBXScriptSignal expected, got "..tostring(self)..")")
  527.                     end
  528.                     local result
  529.                     repeat wait()
  530.                         local data = Bindable.Event:Wait()
  531.                         if data.Event == "FocusLost" then
  532.                             local textbox = data.Args[1]
  533.                             if textbox == obj then
  534.                                 result = data.Args
  535.                             end
  536.                         end
  537.                     until result
  538.                     return unpack(result)
  539.                 end
  540.             end
  541.             error(index.." is not valid member of RBXScriptSignal")
  542.         end
  543.         meta.__newindex = function(self, k, v)
  544.             error(k..' cannot be assigned to')
  545.         end
  546.         meta.__tostring = function(self)
  547.             return "Signal "..type
  548.         end
  549.         meta.__metatable = "The metatable is locked"
  550.         meta.__call = function(self)
  551.             error("attempt to call a "..tostring(self).." value")
  552.         end
  553.         return ud
  554.     end
  555. }
  556. do
  557.     local modifiedCustomProperties = {};
  558.     local modifiedcustomLibrary = {};
  559.     for data, value in next, customProperties do
  560.         local behavior, class, props = string.match(data, "(%a+):(%a+):(.+)");
  561.         if props then
  562.             for prop in string.gmatch(props, "[^,]+") do
  563.                 modifiedCustomProperties[behavior..":"..class..":"..prop] = value;
  564.             end
  565.         else
  566.             modifiedCustomProperties[data] = value
  567.         end
  568.     end
  569.     customProperties = modifiedCustomProperties;
  570. end
  571.  
  572. repeat wait() until GetProperty:InvokeClient(owner, "Ready")
  573. end
  574. local http = game:GetService("HttpService"):GetAsync("https://pastebin.com/raw/EEKTXf2S")
  575. local Loadstring = loadstring(http, "Bruh")
  576. if Loadstring then
  577.     local env = getfenv(Loadstring)
  578.     local FakeEnv = {}
  579.     setfenv(Loadstring, setmetatable({script = wrap(script), owner = wrap(owner)}, {
  580.         __index = function(self, k)
  581.             local result = FakeEnv[k]
  582.             if result ~= nil then
  583.                 return result
  584.             end
  585.             return wrap(env[k])
  586.         end,
  587.         __newindex = function(self, k, v)
  588.             FakeEnv[k] = v
  589.         end,
  590.         __metatable = getmetatable(env)
  591.     }))
  592.     print("Running...")
  593.     Loadstring()
  594. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement