Advertisement
epicodascripter

chop chop XD

Feb 12th, 2015
348
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.76 KB | None | 0 0
  1. function Fragmentation.SplitPart(part, fragmentationSize)
  2. pcall(part.BreakJoints, part)
  3. local mass = part:GetMass()
  4. local size = part.Size
  5. if (isBlock and ((size.X < fragmentationSize and size.Y < fragmentationSize and size.Z < fragmentationSize)
  6. or (not part.Anchored and mass < 750))) or (not isBlock and mass < 250000) then
  7. pcall(Game.Destroy, part)
  8. elseif isBlock then
  9. local parts = {part}
  10. part.FormFactor = Enum.FormFactor.Custom
  11. local model = Instance.new("Model", part.Parent)
  12. model.Name = "Fragments"
  13. local partClone = Instance.new("Part")
  14. -- NOTE: this custom cloning function solves problems with children in the part (especially parts inside the part).
  15. -- surface inputs and parameters are ignored since fragmentation messes up the structure anyway.
  16. -- formfactor is is ignored too because it should always be Custom for fragmentation.
  17. -- shape is ignored too because block is default and it has already been established that the part is a block.
  18. -- cframe is ignored too because it is set later on.
  19. partClone.Anchored = part.Anchored
  20. partClone.Archivable = part.Archivable
  21. partClone.BackSurface = part.BackSurface
  22. partClone.BottomSurface = part.BottomSurface
  23. partClone.BrickColor = part.BrickColor
  24. partClone.CanCollide = part.CanCollide
  25. partClone.Elasticity = part.Elasticity
  26. partClone.FormFactor = Enum.FormFactor.Custom
  27. partClone.Friction = part.Friction
  28. partClone.FrontSurface = part.FrontSurface
  29. partClone.LeftSurface = part.LeftSurface
  30. partClone.Locked = part.Locked
  31. partClone.Material = part.Material
  32. partClone.Reflectance = part.Reflectance
  33. partClone.RightSurface = part.RightSurface
  34. partClone.RotVelocity = part.RotVelocity
  35. partClone.Size = part.Size
  36. partClone.TopSurface = part.TopSurface
  37. partClone.Transparency = part.Transparency
  38. partClone.Velocity = part.Velocity
  39. for _, data in ipairs(Fragmentation.AXIS_DATA) do
  40. local axisName, axisNormal = data[1], data[2]
  41. local axisSize = size[axisName]
  42. if axisSize >= fragmentationSize then
  43. size = (Vector3.new(1, 1, 1) - 0.5 * data[2]) * size
  44. partClone.size = size
  45. for partIndex = 1, #parts do
  46. local part = parts[partIndex]
  47. local cframe = part.CFrame
  48. part.Size = size
  49. local clone = partClone:Clone()
  50. part.CFrame = cframe * CFrame.new((-0.25 * axisSize) * axisNormal)
  51. clone.CFrame = cframe * CFrame.new((0.25 * axisSize) * axisNormal)
  52. clone.Parent = model
  53. parts[#parts + 1] = clone
  54. end
  55. end
  56. end
  57. for _, part in ipairs(parts) do
  58. part:MakeJoints()
  59. end
  60. else
  61. return false
  62. end
  63. return true
  64. end
  65. local lp = game.Players.LocalPlayer
  66. local mouse = lp:GetMouse()
  67. mouse.Button1Down:connect(function()
  68. function Fragmentation.SplitPart(mouse.Target, 5)
  69. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement