MudkipTheEpic

Untitled

Sep 9th, 2017
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.12 KB | None | 0 0
  1. --Use q and e to control--
  2. local function getSizeAndCFrame(part,center,scale)
  3. local size=part.Size*scale
  4. print(size,part.Size)
  5. local cframe=center:toWorldSpace(center:toObjectSpace(part.CFrame)+(center:toObjectSpace(part.CFrame).p*(scale-1)))
  6. return size,cframe
  7. end
  8.  
  9. local function fixMeshes(part,scale)
  10. --clone:ClearAllChildren()
  11. local tMeshes={}
  12. for k,v in pairs(part:children()) do
  13. if v:IsA("DataModelMesh") then
  14. table.insert(tMeshes,v)
  15. end
  16. end
  17. if #tMeshes<0 then return end
  18. for k,mesh in pairs(tMeshes) do
  19. print(mesh:GetFullName())
  20. if mesh:IsA("SpecialMesh") and mesh.MeshType==Enum.MeshType.FileMesh then
  21. mesh.Scale = mesh.Scale * scale
  22. end
  23. end
  24. end
  25.  
  26. local function scaleModel(model,scale)
  27. local center=model:GetModelCFrame()
  28. local tParts={}
  29. local tJoints={}
  30. local function addToTable(instance)
  31. if instance:IsA("JointInstance") then
  32. table.insert(tJoints,{instance,oldParent=instance.Parent})
  33. elseif instance:IsA("BasePart") then
  34. table.insert(tParts,instance)
  35. elseif instance:IsA("ShirtGraphic") then
  36. instance.Graphic=''
  37. instance:Destroy()
  38. elseif instance:IsA("CharacterMesh") or instance:IsA("Clothing") then
  39. instance:Destroy()
  40. end
  41. for k,v in pairs(instance:children()) do
  42. addToTable(v)
  43. end
  44. end
  45. local tSizes={}
  46.  
  47. addToTable(model)
  48. for k,v in pairs(tParts) do
  49. --v.FormFactor="Custom"
  50. tSizes[v]={getSizeAndCFrame(v,center,scale)}
  51. fixMeshes(v,scale)
  52. end
  53. for k,v in pairs(tJoints) do
  54. tSizes[v]={v[1].C0+(v[1].C0.p*(scale-1)),v[1].C1+(v[1].C1.p*(scale-1))}
  55. end
  56. --This cant take too long
  57. for k,v in pairs(tJoints) do
  58. v[1].Parent=nil
  59. end
  60. for k,v in pairs(tParts) do
  61. v.Size,v.CFrame=unpack(tSizes[v])
  62. end
  63. for k,v in pairs(tJoints) do
  64. j=v[1]
  65. j.C0,j.C1=unpack(tSizes[v])
  66. end
  67. for k,v in pairs(tJoints) do
  68. v[1].Parent=v.oldParent
  69. end
  70. return model
  71. end
  72.  
  73. local scale=1
  74.  
  75. while true do
  76. key=game.Players.LocalPlayer:GetMouse().KeyDown:wait()
  77. if key:lower()=="e" --[[and scale>0.5]] then
  78. scale=scale-0.1
  79. scaleModel(game.Players.LocalPlayer.Character,scale/scale+0.1)
  80. elseif key:lower()=="q" --[[and scale<5]] then
  81. scale=scale+0.1
  82. scaleModel(game.Players.LocalPlayer.Character,scale/scale-0.1)
  83. end
  84. end
Advertisement
Add Comment
Please, Sign In to add comment