ForeverDev

Untitled

Nov 8th, 2014
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.10 KB | None | 0 0
  1. function scan(object)
  2.     local objects = {}
  3.     local recurse;
  4.     recurse = function(object)
  5.         for i, v in ipairs(object:GetChildren()) do
  6.             if v:IsA("BasePart") or v:IsA("Model") and not v:IsA("Terrain") then
  7.                 if v:IsA("BasePart") then
  8.                     table.insert(objects, v)
  9.                 end
  10.                 recurse(v)
  11.             end
  12.         end
  13.     end
  14.     recurse(object)
  15.     return objects
  16. end
  17.  
  18. function generateCode(parts)
  19.     local code = "model = Instance.new('Model', Workspace)\n"
  20.     for i, v in ipairs(parts) do
  21.         code = code .. (([[    
  22. NEW = Instance.new("%s", model)
  23. if pcall(function() return NEW.FormFactor end) then
  24.     NEW.FormFactor = %s
  25. end
  26. NEW.Size = Vector3.new(%s)
  27. NEW.CFrame = CFrame.new(%s)
  28. NEW.BrickColor = BrickColor.new("%s")
  29. NEW.Anchored = %s
  30. if %s %% 50 == 0 then
  31.     wait()
  32. end
  33.         ]]):gsub("NEW", "_" .. i):format(
  34.             v.ClassName,
  35.             pcall(function() return v.FormFactor end) and tostring(v.FormFactor) or tostring(Enum.FormFactor.Brick),
  36.             tostring(v.Size),
  37.             tostring(v.CFrame),
  38.             tostring(v.BrickColor),
  39.             tostring(v.Anchored),
  40.             tostring(i)
  41.         ))
  42.     end
  43.     return code
  44. end
  45.  
  46. print(generateCode(scan(Workspace.Model)))
Advertisement
Add Comment
Please, Sign In to add comment