Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Tool = Instance.new('Tool',game.Players.LocalPlayer.Backpack)
- Tool.Name = 'Click for blackhole'
- Tool.CanBeDropped = false
- Tool.RequiresHandle = false
- Tool.ToolTip = ''
- local Handle = Instance.new('Part',Tool)
- local active = false
- Handle.Name = 'Handle'
- Handle.Size = Vector3.new(1,1,1)
- Handle.CanCollide = true
- Handle.Locked = true
- Handle.Transparency = .5
- Handle.BrickColor = BrickColor.Red()
- Handle.Material = 'Neon'
- Tool.Activated:connect(function()
- for i,p in ipairs(Tool.Parent:GetChildren()) do
- if p:IsA("BasePart") then
- p.Anchored = true
- end
- end
- if active == false then
- local active = true
- local model = Instance.new('Model',workspace)
- model.Name = '[Blackhole Script Made By XxDaRobuxTraderxX]'
- local hole = Instance.new('Part')
- hole.Size = Vector3.new(100,100,1)
- hole.Anchored = true
- hole.CanCollide = false
- hole.Locked = true
- hole.CFrame = Handle.CFrame
- hole.BrickColor = BrickColor.Black()
- hole.Parent = model
- hole.Name = 'H'
- local childList = {}
- local massConstant = 100.7 -- Generally a good value
- game.Debris:AddItem(model,5)
- local mass = 320000 * massConstant
- -- This is basically a function that finds all unanchored parts and adds them to childList.
- -- Note: This should only be run once for each object
- function checkObject(obj)
- if (obj ~= hole) and (obj:IsA('BasePart')) then
- if (obj.Anchored == false) then
- table.insert(childList, 1, obj)
- end
- elseif (obj.className == "Model") or (obj:IsA('Accessory')) or (obj.className == "Tool") or (obj == workspace) then
- local child = obj:GetChildren()
- for x = 1, #child do
- checkObject(child[x])
- end
- obj.ChildAdded:connect(checkObject)
- end
- end
- checkObject(workspace)
- print("Black Hole script loaded.")
- local n = 0
- while true do
- if n < #childList then
- n = n + 1
- if n % 800 == 0 then
- wait()
- end
- else
- n = 1
- wait()
- end
- local child = childList[n]
- if (child:IsA('BasePart')) and (child.Anchored == false) then
- local relPos = hole.Position - child.Position
- local motivator = child:FindFirstChild("BlackHole Influence")
- if relPos.magnitude * 240 * massConstant < mass then
- child:BreakJoints()
- if (relPos.magnitude * 320 * massConstant < mass) and (child.Size.z + hole.Size.x > relPos.magnitude * 2 - 4) then
- mass = mass + child:GetMass()
- child:Remove()
- table.remove(childList, n)
- n = n - 1 -- This is the reason I need a counter of my own design
- else
- child.CanCollide = false -- I Can assume that things won't escape the black hole.
- if motivator == nil then
- motivator = Instance.new("BodyPosition")
- motivator.Parent = child
- motivator.Name = "BlackHole Influence"
- end
- motivator.position = hole.Position
- motivator.maxForce = Vector3.new(1, 1, 1) * mass * child:GetMass() / (relPos.magnitude * massConstant)
- end
- elseif motivator ~= nil then
- motivator:Remove()
- end
- end
- end
- end
- end)--end of tool function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement