Advertisement
Guest User

Untitled

a guest
May 23rd, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.91 KB | None | 0 0
  1. local Tool = Instance.new('Tool',game.Players.LocalPlayer.Backpack)
  2. Tool.Name = 'Click for blackhole'
  3. Tool.CanBeDropped = false
  4. Tool.RequiresHandle = false
  5. Tool.ToolTip = ''
  6. local Handle = Instance.new('Part',Tool)
  7. local active = false
  8. Handle.Name = 'Handle'
  9. Handle.Size = Vector3.new(1,1,1)
  10. Handle.CanCollide = true
  11. Handle.Locked = true
  12. Handle.Transparency = .5
  13. Handle.BrickColor = BrickColor.Red()
  14. Handle.Material = 'Neon'
  15. Tool.Activated:connect(function()
  16. for i,p in ipairs(Tool.Parent:GetChildren()) do
  17. if p:IsA("BasePart") then
  18. p.Anchored = true
  19. end
  20. end
  21. if active == false then
  22. local active = true
  23.  
  24. local model = Instance.new('Model',workspace)
  25. model.Name = '[Blackhole Script Made By grabknife1002]'
  26. local hole = Instance.new('Part')
  27. hole.Size = Vector3.new(100,100,1)
  28. hole.Anchored = true
  29. hole.CanCollide = false
  30. hole.Locked = true
  31. hole.CFrame = Handle.CFrame
  32. hole.BrickColor = BrickColor.Black()
  33. hole.Parent = model
  34. hole.Name = 'H'
  35. local childList = {}
  36. local massConstant = 100.7 -- Generally a good value
  37. game.Debris:AddItem(model,5)
  38. local mass = 320000 * massConstant
  39.  
  40. -- This is basically a function that finds all unanchored parts and adds them to childList.
  41. -- Note: This should only be run once for each object
  42. function checkObject(obj)
  43. if (obj ~= hole) and (obj:IsA('BasePart')) then
  44. if (obj.Anchored == false) then
  45. table.insert(childList, 1, obj)
  46. end
  47. elseif (obj.className == "Model") or (obj:IsA('Accessory')) or (obj.className == "Tool") or (obj == workspace) then
  48. local child = obj:GetChildren()
  49. for x = 1, #child do
  50. checkObject(child[x])
  51. end
  52. obj.ChildAdded:connect(checkObject)
  53. end
  54. end
  55.  
  56. checkObject(workspace)
  57.  
  58. print("Black Hole script loaded.")
  59.  
  60. local n = 0
  61. while true do
  62. if n < #childList then
  63. n = n + 1
  64. if n % 800 == 0 then
  65. wait()
  66. end
  67. else
  68. n = 1
  69. wait()
  70. end
  71.  
  72. local child = childList[n]
  73. if (child:IsA('BasePart')) and (child.Anchored == false) then
  74. local relPos = hole.Position - child.Position
  75. local motivator = child:FindFirstChild("BlackHole Influence")
  76. if relPos.magnitude * 240 * massConstant < mass then
  77. child:BreakJoints()
  78. if (relPos.magnitude * 320 * massConstant < mass) and (child.Size.z + hole.Size.x > relPos.magnitude * 2 - 4) then
  79. mass = mass + child:GetMass()
  80. child:Remove()
  81. table.remove(childList, n)
  82. n = n - 1 -- This is the reason I need a counter of my own design
  83. else
  84. child.CanCollide = false -- I Can assume that things won't escape the black hole.
  85. if motivator == nil then
  86. motivator = Instance.new("BodyPosition")
  87. motivator.Parent = child
  88. motivator.Name = "BlackHole Influence"
  89. end
  90. motivator.position = hole.Position
  91. motivator.maxForce = Vector3.new(1, 1, 1) * mass * child:GetMass() / (relPos.magnitude * massConstant)
  92. end
  93. elseif motivator ~= nil then
  94. motivator:Remove()
  95. end
  96. end
  97. end
  98. end
  99. end)--end of tool function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement