Advertisement
advancedev

peace

Jan 21st, 2015
329
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.46 KB | None | 0 0
  1. local MaxPieces = 20
  2. local Explode = true
  3. local Connection = nil
  4. function IsWhole(Number)
  5. return math.ceil(Number) == Number
  6. end
  7. function ChangeAxis(Vector,Axis,Value)
  8. if(Axis == "x")then
  9. return Vector3.new(Value,Vector.y,Vector.z)
  10. end
  11. if(Axis == "y")then
  12. return Vector3.new(Vector.x,Value,Vector.z)
  13. end
  14. if(Axis == "z")then
  15. return Vector3.new(Vector.x,Vector.y,Value)
  16. end
  17. end
  18. d=false
  19. function split(obj)
  20. if obj.Name ~= "Base" then
  21. if d== false then
  22. d=true
  23. local Targ = obj
  24. local FF = 1
  25. if(Targ.formFactor == Enum.FormFactor.Symmetric)then
  26. FF = 1
  27. end
  28. if(Targ.formFactor == Enum.FormFactor.Brick)then
  29. FF = 1.2
  30. end
  31. if(Targ.formFactor == Enum.FormFactor.Plate)then
  32. FF = 0.4
  33. end
  34. local New = Targ:Clone()
  35. local Rotation = Targ.CFrame - Targ.CFrame.p
  36. local SizeFactorX = 1
  37. local SizeFactorY = FF
  38. local SizeFactorZ = 1
  39. local Extra = (Targ.Size.x*Targ.Size.y*Targ.Size.z/(SizeFactorX*SizeFactorY*SizeFactorZ))/MaxPieces
  40. while Extra > 1 do
  41. SizeFactorX = SizeFactorX * 2
  42. SizeFactorY = SizeFactorY * 2
  43. SizeFactorZ = SizeFactorZ * 2
  44. if(SizeFactorX > Targ.Size.x)then
  45. SizeFactorX = Targ.Size.x
  46. end
  47. if(SizeFactorY > Targ.Size.y)then
  48. SizeFactorY = Targ.Size.y
  49. end
  50. if(SizeFactorZ > Targ.Size.z)then
  51. SizeFactorZ = Targ.Size.z
  52. end
  53. Extra = (Targ.Size.x*Targ.Size.y*Targ.Size.z/(SizeFactorX*SizeFactorY*SizeFactorZ))/MaxPieces
  54. wait()
  55. end
  56. local Start = Targ.Position - (Targ.CFrame.lookVector * (Targ.Size.z/2 + (SizeFactorZ / 2)))-((Targ.CFrame * CFrame.fromEulerAnglesXYZ(0,math.pi/2,0)).lookVector * (Targ.Size.x/2 + (SizeFactorX / 2)))-((Targ.CFrame * CFrame.fromEulerAnglesXYZ(math.pi/2,0,0)).lookVector * (Targ.Size.y/2 + (SizeFactorY/2)))
  57. New.Size = Vector3.new(SizeFactorX,SizeFactorY,SizeFactorZ)
  58. local OverShootZ = (Targ.Size.z/SizeFactorZ) - math.floor(Targ.Size.z/SizeFactorZ)
  59. local OverShootX = (Targ.Size.x/SizeFactorX) - math.floor(Targ.Size.x/SizeFactorX)
  60. local OverShootY = (Targ.Size.y/SizeFactorY) - math.floor(Targ.Size.y/SizeFactorY)
  61. print("SizeFactor",SizeFactorX,SizeFactorY,SizeFactorZ)
  62. print("OverShoot",OverShootX,OverShootY,OverShootZ)
  63. for z = 1,math.ceil(Targ.Size.z/SizeFactorZ) do
  64. if(OverShootZ > 0)then
  65. if(z == math.ceil(Targ.Size.z/SizeFactorZ))then
  66. z = z - ((1 - OverShootZ) / 2)
  67. New.Size = ChangeAxis(New.Size,"z",OverShootZ * SizeFactorZ)
  68. else
  69. New.Size = ChangeAxis(New.Size,"z",SizeFactorZ)
  70. end
  71. end
  72. for y = 1,math.ceil(Targ.Size.y/SizeFactorY) do
  73. if(OverShootY > 0)then
  74. if(y == math.ceil(Targ.Size.y/SizeFactorY))then
  75. y = y - ((1 - OverShootY) / 2)
  76. New.Size = ChangeAxis(New.Size,"y",OverShootY * SizeFactorY)
  77. else
  78. New.Size = ChangeAxis(New.Size,"y",SizeFactorY)
  79. end
  80. end
  81. for x = 1,math.ceil(Targ.Size.x/SizeFactorX) do
  82. if(OverShootX > 0)then
  83. if(x == math.ceil(Targ.Size.x/SizeFactorX))then
  84. x = x - ((1 - OverShootX) / 2)
  85. New.Size = ChangeAxis(New.Size,"x",OverShootX * SizeFactorX)
  86. else
  87. New.Size = ChangeAxis(New.Size,"x",SizeFactorX)
  88. end
  89. end
  90. local N = New:Clone()
  91. N.CFrame = CFrame.new(Start + (Targ.CFrame.lookVector * z * SizeFactorZ)+((Targ.CFrame * CFrame.fromEulerAnglesXYZ(0,math.pi/2,0)).lookVector * x * SizeFactorX)+((Targ.CFrame * CFrame.fromEulerAnglesXYZ(math.pi/2,0,0)).lookVector * y * SizeFactorY))*Rotation
  92. N.Parent = game.Workspace
  93. end
  94. end
  95. end
  96. Targ:Remove()
  97. end
  98. wait(4)
  99. d=false
  100. end
  101. end
  102.  
  103.  
  104. split(game.Workspace.advancedev.Head)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement