Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How would i make this script not kill and not take damage?

Asked by 8 years ago

local hole = script.Parent local childList = {}

local massConstant = 5.8 -- Generally a good value

local mass = 32000 * 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.className == "Part") then if (obj.Anchored == false) then table.insert(childList, 1, obj) end elseif (obj.className == "Model") or (obj.className == "Hat") 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 ~= hole) and (child.className == "Part") 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 = true -- 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

0
and how would i adjust the range Jakuten 5 — 8y

Answer this question