Advertisement
XZTablets

SynScriptDumper

Aug 29th, 2020
2,525
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.09 KB | None | 0 0
  1. local MaxThreads = 20;
  2.  
  3. local MarketplaceService = game:GetService("MarketplaceService");
  4.  
  5. local PlaceId = game.PlaceId;
  6. local PlaceName;
  7.  
  8. local Success, GameInfo = pcall(function()
  9.     return MarketplaceService:GetProductInfo(PlaceId);
  10. end)
  11.  
  12. if Success then
  13.     PlaceName = GameInfo.Name;
  14. else
  15.     error(PlaceId,"not recognised.");
  16. end
  17.  
  18. local FolderName = PlaceName.." Script Dump";
  19.  
  20. makefolder(FolderName);
  21.  
  22. local ParentsToCheck = {
  23.     workspace,
  24.     game.Players.LocalPlayer.PlayerGui,
  25.     game.ReplicatedStorage
  26. }
  27.  
  28. local Scripts = {};
  29.  
  30. for _, Parent in next, ParentsToCheck do
  31.     for _, Descendant in next, Parent:GetDescendants() do
  32.         if Descendant:IsA("LocalScript") or Descendant:IsA("ModuleScript") then
  33.             table.insert(Scripts, Descendant);
  34.         end
  35.     end
  36. end
  37.  
  38. local ScriptsToDecompile = (#Scripts);
  39. local Decompiled = 0;
  40. local Progress = Decompiled / ScriptsToDecompile;
  41.  
  42. function GetUserResolution()
  43.     local UserTest = Instance.new("ScreenGui", game:GetService("CoreGui"));
  44.     local Size = UserTest.AbsoluteSize;
  45.     UserTest:Destroy();
  46.     return Size.X, Size.Y;
  47. end
  48.  
  49. local SizeX, SizeY = GetUserResolution();
  50.  
  51. local Tracker = Drawing.new("Square");
  52. Tracker.Size = Vector2.new(702,32);
  53. Tracker.Position = Vector2.new((SizeX/2)-(702/2),(SizeY-(32+5)));
  54. Tracker.Color = Color3.fromRGB(0,0,0);
  55. Tracker.Filled = true;
  56. Tracker.Visible = true;
  57.  
  58. local Fill = Drawing.new("Square");
  59. Fill.Size = Vector2.new(Progress*700,30);
  60. Fill.Position = Vector2.new((SizeX/2)-(700/2),(SizeY-(31+5)));
  61. Fill.Color = Color3.fromRGB(255,255,255);
  62. Fill.Filled = true;
  63. Fill.Visible = true;
  64.  
  65. local Decompiling = Drawing.new("Text");
  66. Decompiling.Size = 20;
  67. Decompiling.Color = Color3.fromRGB(255,255,255);
  68. Decompiling.Text = "Decompiling "..ScriptsToDecompile.." scripts.";
  69. Decompiling.Visible = true;
  70.  
  71. function UpdateText()
  72.     local DSizeX, DSizeY = Decompiling.TextBounds.X, Decompiling.TextBounds.Y;
  73.     Decompiling.Position = Vector2.new((SizeX/2)-(DSizeX/2),(SizeY-5));
  74. end
  75.  
  76. UpdateText();
  77.  
  78. local Hierarchy = {
  79.     [FolderName] = {
  80.        
  81.     }
  82. }
  83.  
  84. function UpdateFill()
  85.     local FillX = (Progress * 700);
  86.     Fill.Size = Vector2.new(FillX,30);
  87.     Fill.Position = Vector2.new((SizeX/2)-(FillX/2),(SizeY-(31+5)));
  88. end
  89.  
  90. function MakeHierarchy(FromDirectory)
  91.     local StartDirectory = FolderName;
  92.     local ToCheck = FromDirectory:split("/");
  93.     table.remove(ToCheck);
  94.     local Start = Hierarchy[StartDirectory];
  95.     local Checked = {};
  96.    
  97.     for Idx, Parent in next, ToCheck do
  98.         table.insert(Checked, Parent);
  99.         if not Start[Parent] then
  100.             Start[Parent] = {};
  101.             makefolder(FolderName.."/"..table.concat(Checked, "/"))
  102.         end
  103.         Start = Start[Parent];
  104.     end
  105. end
  106.  
  107. wait(1);
  108.  
  109. local StartTick = tick();
  110.  
  111. local CurrentThreads = 0;
  112.  
  113. local Threads = {};
  114.  
  115. function TryNewThread(Script)
  116.     if (CurrentThreads >= MaxThreads) then
  117.         spawn(function()
  118.             repeat
  119.                 wait()
  120.             until (CurrentThreads < MaxThreads)
  121.             TryNewThread(Script);
  122.         end)
  123.     else
  124.         table.insert(Threads, Script)
  125.         CurrentThreads = CurrentThreads + 1;
  126.         spawn(function()
  127.             MakeHierarchy(Script:GetFullName():gsub("%.", "/"));
  128.             pcall(function()
  129.                 Decompiling.Text = "Decompiling: game."..Script:GetFullName();
  130.             end)
  131.             pcall(UpdateText);
  132.             writefile(FolderName.."/"..Script:GetFullName():gsub("%.", "/")..".lua", decompile(Script));
  133.             Decompiled = Decompiled + 1;
  134.             Progress = Decompiled / ScriptsToDecompile;
  135.             pcall(UpdateFill);
  136.             CurrentThreads = CurrentThreads - 1;
  137.         end)
  138.     end
  139. end
  140.  
  141. for _, Script in next, Scripts do
  142.     TryNewThread(Script);
  143. end
  144.  
  145. repeat
  146.     wait()
  147. until (#Threads == ScriptsToDecompile)
  148.  
  149. local TimeTaken = tick() - StartTick;
  150.  
  151. writefile(FolderName.."/".."log.txt", "Time Taken: "..TimeTaken.."ms.\nScripts Decompiled: "..ScriptsToDecompile..".");
  152.  
  153. Tracker:Remove();
  154. Fill:Remove();
  155. Decompiling:Remove();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement