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

Which Part of This Script Kills You?

Asked by 10 years ago

I'm trying to make it so a Subspace Bomb is fixed (as in it won't suck you in and kill you) and I can't seem to find the part where it kills you. Here's the script without the part where it's getting bigger.

function onTouched(part)

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

    if h~=nil then

wait(0.001)
h.Health = 0
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 = 200000 * 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.")

Getting bigger...

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


1 answer

Log in to vote
0
Answered by 10 years ago

I think it is h.Health = 0 where "h" refers to "humanoid"

So to explain more, h.Humanoid gets the health of the humanoid to change it. While number 0 changes the humanoid's health to 0 and kills him.

I am not sure about that, try it and tell me if it works.

0
It didn't work, but I found a solution. Stay at least 25 studs away or it will start to pull you in. DapperLink123 30 — 10y
0
Congratulations! kudorey619 138 — 10y
Ad

Answer this question