This is what i have so far

function onTouched(part)

local h = part.Parent:findFirstChild("Humanoid")

if h~=nil then

wait(0.001) h.Health = 100 children = h.Parent:children()

for i=1,#children do

	if(children[i].className == "Part" and children[i].Name ~= "Torso") then stick(children[i], h.Parent.Torso) end

	if(children[i].className == "Hat") then stick(children[i].Handle, h.Parent.Torso) end

end

h.Parent.Head.Velocity = h.Parent.Head.Velocity + Vector3.new(5,0,0)

end

end

script.Parent.Touched:connect(onTouched)local hole = script.Parent

local childList = {}

local childSize = {}

local massConstant = 1

local mass = 100000 * massConstant

function checkObject(obj)

if (obj ~= hole) and (obj.className == "Part") then

	if (obj.Anchored == false) then

		table.insert(childList, 1, obj)

		table.insert(childSize, 1, obj.Size)

	end

else

	if (obj.className == "Model") or (obj == workspace) then

		local child = obj:GetChildren()

		for x = 1, #child do

			if (child[x] ~= hole) and (child[x].className == "Part") and (child[x].Anchored == false) then

				table.insert(childList, 1, child[x])

				table.insert(childSize, 1, child[x].Size)

			end

			if child[x].className == "Model" then

				checkObject(child[x])

			end

		end

		obj.ChildAdded:connect(checkObject)

	end

end

end

checkObject(workspace)

function cross(v1, v2)

return Vector3.new(v1.y * v2.z - v2.y * v1.z, v1.z * v2.x - v1.x * v2.z, v1.x * v2.y - v2.x * v1.y)

end

print("Black Hole script loaded.")

local min = 0

local max = 10

while true do

wait()

local n = 0

while n < #childList do

	if n % 800 == 0 then

		wait()

	end

	n = n + 1

	local child = childList[n]

	if (child ~= hole) and (child.className == "Part") and (child.Anchored == false) then

		local relPos = hole.Position - child.Position

		if relPos.magnitude * 240 * massConstant < mass then

			child.RotVelocity = cross(child.CFrame.lookVector, relPos) * 20 / relPos.magnitude

			local canContinue = true

			if relPos.magnitude * 320 * massConstant < mass then

				local length = mass / (320 * relPos.magnitude * massConstant)

				if childSize[n].z * length >  relPos.magnitude * 2 then

					mass = mass + child:GetMass()

					child:Remove()

					table.remove(childList, n)

					table.remove(childSize, n)

					canContinue = false

					n = n - 1

				else

					child.CanCollide = false

				end

			end

			if canContinue then

				local motivator = child:FindFirstChild("BlackHole Influence")

				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

		else

			local motivator = child:FindFirstChild("BlackHole Influence")

			if motivator ~= nil then

				motivator:Remove()

			end

		end

	end

end

end

It instantly kills when it hits the object and it instantly removes the character. How would i fix this?

2 comments

1

fix your formatting?

0

Still not fixed..