Advertisement
Guest User

Protosmasher

a guest
Jan 6th, 2020
1,558
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.55 KB | None | 0 0
  1. -- Revelation216's SaveInstance Protosmasher Script
  2. -- Big black clock#3068
  3.  
  4. local SETTINGS = {
  5. SAVE_AS = "FILENAME"; -- File Name to Save As (Find in your Protosmasher Folder [workspace>saved])
  6. DECOMPILE_SCRIPTS = true; -- Use if you want to Decompile Scripts (TAKES A LONG TIME FOR A LOT OF SCRIPTS!!!!, Will Decompile ALL SCRIPTS for Enabled WHERE_TO_SAVE)
  7. OUTPUT_MODE = "OUT"; -- "LOGS" Logs for Dev Console (F9) or "OUT" Output in Protosmasher (Out is more secure)
  8. SAFE_MODE = false; -- Use if an Anti-Exploit detects this SaveInstance Script (Doesn't Toggle Bool for Archivable Instances from false to true)
  9. TERRAIN_SAVE = false; -- Uses Protosmasher's saveinstance to Save Terrain to a seperate File named "Terrain_FILENAME"
  10.  
  11. WHERE_TO_SAVE = {
  12. Workspace = true;
  13. Lighting = true;
  14. ReplicatedFirst = true;
  15. ReplicatedStorage = true;
  16. JointsService = true;
  17. Players = true;
  18. StarterGui = true;
  19. Nil = false; -- Only Saves LocalScripts, ModuleScripts, and Folders (with Children) in Nil
  20. };
  21.  
  22. Version = "1.7.5";
  23. Change_Log = "1.5.0\n- Public release\n1.7.5\n- Fixed bugs with Nil\n- Fixed Saving process";
  24. }
  25.  
  26. local SaveModel = Instance.new("Model")
  27. SaveModel.Name = "DataModel"
  28.  
  29. local Output = function(String)
  30. if SETTINGS.OUTPUT_MODE == "OUT" then
  31. printoutput("\n[RSI]: \n"..tostring(String))
  32. elseif SETTINGS.OUTPUT_MODE == "LOGS" then
  33. print("\n[RSI]: \n"..String)
  34. end
  35. end
  36.  
  37. local DecompileScript = function(Script)
  38. local DisabledState
  39. local SV = Instance.new("StringValue")
  40. SV.Name = Script.Name.."_"..Script.ClassName
  41.  
  42. if Script.ClassName == "LocalScript" then
  43. DisabledState = Script.Disabled
  44. Script.Disabled = true
  45. end
  46.  
  47. if SETTINGS.DECOMPILE_SCRIPTS == true then
  48. if decompile then
  49. local Source
  50.  
  51. if Script.ClassName == "LocalScript" or Script.ClassName == "ModuleScript" then
  52. local Run, Err = pcall(function() Source = decompile(Script) end)
  53. if Err then Output("Decompiler Ran into Error (skipped source) :\n"..tostring(Err)) Source = "DECOMPILER ERROR" end
  54. end
  55.  
  56. if tostring(Source) == "false" then
  57. SV.Value = "DECOMPILER IS PATCHED OR HAS ERRORED"
  58. else
  59. SV.Value = Source
  60. end
  61. elseif not decompile then
  62. SV.Value = "DECOMPILER NOT FOUND"
  63. end
  64. else
  65. SV.Value = "DECOMPILER DISABLED FROM SCRIPT"
  66. end
  67.  
  68. if Script.ClassName == "LocalScript" then
  69. Script.Disabled = DisabledState
  70. end
  71.  
  72. return SV
  73. end
  74.  
  75.  
  76.  
  77. local CreateBool = function(instance)
  78. if SETTINGS.SAFE_MODE == true then
  79. local Bool = Instance.new("BoolValue")
  80. Bool.Name = tostring(instance).."_ANTIEXPLOIT_SETTING_ENABLED_ARCHIVABLE_FALSE"
  81.  
  82. return Bool
  83. else
  84. local Bool = Instance.new("BoolValue")
  85. Bool.Name = tostring(instance)
  86.  
  87. return Bool
  88. end
  89. end
  90.  
  91. local Clone = function(Tree)
  92. local CTree
  93.  
  94. if Tree.ClassName == "Player" then
  95. local Replace = Instance.new("Folder")
  96. Replace.Name = Tree.Name
  97. CTree = Replace
  98.  
  99. for Index, Child in pairs(Tree:GetChildren()) do
  100. local NewFolder = Instance.new("Folder")
  101. NewFolder.Name = Child.Name
  102.  
  103. for Ind, Chil in pairs(Child:GetChildren()) do
  104. Chil = Chil:Clone()
  105. Chil.Parent = NewFolder
  106. end
  107.  
  108. NewFolder.Parent = CTree
  109. end
  110. elseif Tree.ClassName == "Folder" then
  111. local Replace = Instance.new("Folder")
  112. Replace.Name = Tree.Name
  113. CTree = Replace
  114.  
  115. for Ind, Child in pairs(Tree:GetChildren()) do
  116. Child = Child:Clone()
  117. Child.Parent = Replace
  118. end
  119. else
  120. CTree = Tree:Clone()
  121. end
  122.  
  123. if CTree ~= nil then
  124. for Index, Des in pairs(CTree:GetDescendants()) do
  125. if Des.ClassName == "LocalScript" or Des.ClassName == "ModuleScript" then
  126. local Dec = DecompileScript(Des)
  127. local ParentofDes = Des.Parent
  128.  
  129. for I, Child in pairs(Des:GetChildren()) do
  130. Child.Parent = Dec
  131. end
  132.  
  133. Des.Parent = game.RobloxReplicatedStorage --// Yes I know, but it would show in nil when destroyed sooo eh
  134. Dec.Parent = ParentofDes
  135. end
  136. end
  137.  
  138. if CTree.ClassName == "LocalScript" or CTree.ClassName == "ModuleScript" then
  139. local DecompiledScript = DecompileScript(CTree)
  140.  
  141. for I, Child in pairs(CTree:GetChildren()) do
  142. Child.Parent = DecompiledScript
  143. end
  144.  
  145. CTree.Parent = game.RobloxReplicatedStorage
  146. CTree = DecompiledScript
  147. end
  148. else
  149. return CreateBool("Nil")
  150. end
  151.  
  152. return CTree
  153. end
  154.  
  155. local SaveInstance = function(instance, DoSave)
  156. local IndexFolder
  157.  
  158. if DoSave == true then
  159. IndexFolder = Instance.new("Folder")
  160. IndexFolder.Name = instance.Name
  161. IndexFolder.Parent = SaveModel
  162. else
  163. IndexFolder = Instance.new("Folder")
  164. IndexFolder.Name = instance.Name.."_NOT_ENABLED"
  165. IndexFolder.Parent = SaveModel
  166. end
  167.  
  168. local Save = function(InsToSave)
  169. if InsToSave ~= game.Workspace.Terrain and InsToSave ~= game.Workspace.Camera and InsToSave ~= nil then
  170. if InsToSave.ClassName == "LocalScript" or InsToSave.ClassName == "ModuleScript" then
  171. local Dec = DecompileScript(InsToSave)
  172. Dec.Parent = IndexFolder
  173. else
  174. local ToParent
  175.  
  176. if InsToSave.Archivable == false and SETTINGS.SAFE_MODE == false then
  177. InsToSave.Archivable = true
  178.  
  179. for i, Desn in pairs(InsToSave:GetDescendants()) do
  180. if Desn.Archivable == false then
  181. Desn.Archivable = true
  182. end
  183. end
  184.  
  185. ToParent = Clone(InsToSave)
  186. elseif InsToSave.Archivable == true and SETTINGS.SAFE_MODE == false then
  187. ToParent = Clone(InsToSave)
  188. elseif SETTINGS.SAFE_MODE == true and InsToSave.Archivable == true then
  189. ToParent = Clone(InsToSave)
  190. elseif SETTINGS.SAFE_MODE == true and InsToSave.Archivable == false then
  191. local Ins = CreateBool(InsToSave)
  192. ToParent = IndexFolder
  193. end
  194.  
  195. ToParent.Parent = IndexFolder
  196. end
  197. else
  198. if InsToSave == game.Workspace.Terrain and SETTINGS.TERRAIN_SAVE == true then
  199. Output("Saving Terrain as: Terrain_"..SETTINGS.SAVE_AS)
  200.  
  201. if saveinstance then
  202. saveinstance(InsToSave, "Terrain_"..SETTINGS.SAVE_AS, false)
  203. else
  204. error("saveinstance NOT FOUND!")
  205. end
  206. else
  207. local Ins = CreateBool(InsToSave)
  208. Ins.Parent = IndexFolder
  209. end
  210. end
  211. end
  212.  
  213. local Children = instance:GetChildren()
  214.  
  215. if #Children >= 1 and DoSave == true then
  216. for Index, Child in pairs(Children) do
  217. Save(Child)
  218. end
  219. elseif #Children == 0 and DoSave == true then
  220. instance = instance.Name.."_NO_CHILDREN"
  221. IndexFolder = CreateBool(instance)
  222. end
  223.  
  224. Output("Instance: "..tostring(instance.Name).."\nSaved: "..tostring(DoSave).."\nChildren: "..tostring(#Children))
  225. end
  226.  
  227. local Start = function()
  228. Output("Begining Compilation of DataModel...")
  229.  
  230. SaveInstance(game:GetService("Workspace"), SETTINGS.WHERE_TO_SAVE.Workspace)
  231.  
  232. SaveInstance(game:GetService("Lighting"), SETTINGS.WHERE_TO_SAVE.Lighting)
  233.  
  234. SaveInstance(game:GetService("ReplicatedFirst"), SETTINGS.WHERE_TO_SAVE.ReplicatedFirst)
  235.  
  236. SaveInstance(game:GetService("ReplicatedStorage"), SETTINGS.WHERE_TO_SAVE.ReplicatedStorage)
  237.  
  238. SaveInstance(game:GetService("JointsService"), SETTINGS.WHERE_TO_SAVE.JointsService)
  239.  
  240. SaveInstance(game:GetService("Players"), SETTINGS.WHERE_TO_SAVE.Players)
  241.  
  242. SaveInstance(game:GetService("StarterGui"), SETTINGS.WHERE_TO_SAVE.StarterGui)
  243.  
  244. if SETTINGS.WHERE_TO_SAVE.Nil == true then
  245. if get_nil_instances then
  246. local Nil = Instance.new("Folder")
  247. Nil.Name = "Nil"
  248. Nil.Parent = SaveModel
  249.  
  250. for Index, Nilled in pairs(get_nil_instances()) do
  251. if Nilled.ClassName == "LocalScript" or Nilled.ClassName == "ModuleScript" then
  252. local Script = DecompileScript(Nilled)
  253. Script.Parent = Nil
  254. elseif Nilled.ClassName == "Folder" then
  255. print("Fold: "..tostring(Nilled))
  256. local Cl = Clone(Nilled)
  257. Cl.Parent = Nil
  258. end
  259. end
  260. else
  261. Output("get_nil_instances NOT FOUND")
  262.  
  263. local Nil = Instance.new("Folder")
  264. Nil.Name = "Nil_NOT_FOUND"
  265. Nil.Parent = SaveModel
  266. end
  267. else
  268. local Nil = Instance.new("Folder")
  269. Nil.Name = "Nil_NOT_ENABLED"
  270. Nil.Parent = SaveModel
  271. end
  272.  
  273. Output("Instance: Nil\nSaved: "..tostring(SETTINGS.WHERE_TO_SAVE.Nil))
  274.  
  275. Output("Compiled DataModel!\nSaving DataModel as: "..SETTINGS.SAVE_AS)
  276.  
  277. if saveinstance then
  278. saveinstance(SaveModel, SETTINGS.SAVE_AS, false)
  279. else
  280. Output("saveinstance NOT FOUND!")
  281. end
  282. end
  283.  
  284. Output("Big Black Clocks Protosmasher SaveInstance Script\nVersion: "..SETTINGS.Version.."\n"..SETTINGS.Change_Log)
  285.  
  286. local run, err = pcall(Start)
  287.  
  288. if err then
  289. Output("An Error occured!\nRevelation216#6140 for bugs\n"..err)
  290. else
  291. Output("Successfully Saved DataModel")
  292. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement