AnonymousHaxs

A1_exe's Instance.fake

Mar 29th, 2018 (edited)
357
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.97 KB | None | 0 0
  1. --[[
  2.     Credit Rerumu for introducing me to this technique.
  3.     cc. 2018
  4. ]]
  5.  
  6. local Objects, Types = {}, {Color3 = Color3.new();CFrame = CFrame.new();Vector2 = Vector2.new();Vector3 = Vector3.new();BrickColor = BrickColor.new();Rect = Rect.new();UDim = UDim.new();UDim2 = UDim2.new();NumberRange = NumberRange.new(0,0);NumberSequenceKeypoint = NumberSequenceKeypoint.new(0,0,0);NumberSequence = NumberSequenceKeypoint.new(0,0,0);ColorSequenceKeypoint = ColorSequenceKeypoint.new(0, Color3.new());ColorSequence = ColorSequence.new({ColorSequenceKeypoint.new(0, Color3.new());ColorSequenceKeypoint.new(1, Color3.new());})};
  7. local Classes do
  8.     for i = 1, 10 do
  9.         local Loaded = pcall(function()
  10.             Classes = game:HttpGet('http://anaminus.github.io/rbx/json/api/latest.json', true)
  11.         end)
  12.        
  13.         if Loaded then
  14.             Classes = game.HttpService:JSONDecode(Classes);
  15.             break
  16.         else
  17.             wait(3/10) 
  18.         end
  19.     end
  20. end
  21.  
  22. for __ = 1, #(Classes) do
  23.     local Value = Classes[__]
  24.     if (Value.type == 'Class') then
  25.         Objects[Value.Name] = Value;
  26.         Objects[Value.Name]['Properties'] = {};
  27.     elseif (Value.type == 'Property') then
  28.         local Ignore do
  29.             for _, T in next, (Value.tags) do
  30.                 if (T == 'deprecated')or (T == 'hidden') then
  31.                     Ignore = true
  32.                     break
  33.                 end
  34.             end
  35.         end
  36.        
  37.         if (not Ignore) then
  38.             local Props = Objects[Value.Class].Properties
  39.             Props[#Props + 1] = Value
  40.         end
  41.     end
  42. end
  43.  
  44. local Instance = Instance
  45. Instance = { new = Instance.new;
  46.     fake = function(ClassName, Parent)
  47.         local Ret, Recurse = {};
  48.         Recurse = function(class)
  49.             local Class = Objects[class]
  50.             if Class then
  51.                 for __, Prop in next, (Class.Properties) do
  52.                     if not Ret[Prop.Name] then
  53.                         if Types[Prop.ValueType] then
  54.                             Ret[Prop.Name] = Types[Prop.ValueType]
  55.                         elseif (Prop.ValueType == 'bool') then
  56.                             if (Prop.Default) then
  57.                                 Ret[Prop.Name] = (Prop.Default:match('true') and true) or false
  58.                             else
  59.                                 Ret[Prop.Name] = false
  60.                             end
  61.                         elseif (Prop.ValueType == 'float') or (Prop.ValueType == 'int') then
  62.                             if (Prop.Default) then
  63.                                 Ret[Prop.Name] = tonumber(Prop.Default) or 0
  64.                             else
  65.                                 Ret[Prop.Name] = 0
  66.                             end
  67.                         elseif (Prop.ValueType == 'string')then
  68.                             if (Prop.Default) then
  69.                                 Ret[Prop.Name] = Prop.Default
  70.                             else
  71.                                 Ret[Prop.Name] = ''
  72.                             end
  73.                         end
  74.                     end
  75.                 end
  76.                
  77.                 if Class['Superclass'] then
  78.                     Recurse(Class['Superclass'])
  79.                 end
  80.             end        
  81.         end
  82.         Recurse(ClassName) 
  83.        
  84.         Ret['ClassName'] = ClassName
  85.         if Parent then
  86.             Ret['Parent'] = Parent
  87.         end
  88.        
  89.         return setmetatable(Ret, {
  90.             --__metatable = getmetatable(game);
  91.             __call = function(Props)
  92.                 for Name, Val in next, (self, Props) do
  93.                     Ret[Name] = Val
  94.                 end
  95.                
  96.                 return Ret
  97.             end
  98.         })
  99.     end
  100. }
  101.  
  102. -- EXAMPLE -- (Works Exactly Like Create But Better)
  103. local I = Instance.fake('StringValue', workspace){
  104.     Name        = 'Value',
  105.     Value         = '',
  106. }
  107.  
  108. print(I)
  109. ------------
Add Comment
Please, Sign In to add comment