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

Working on a damaging script however the script doesn't run nor show any errors?

Asked by 4 years ago

So I've modifying this old script (I did not make it I'm just modifying it to my liking) and it was originally a black hole script but now I just made it so it could only unanchor parts and make them fall off the map within a certain range of the part that contains the script. I've been having problems where the script doesn't run for some reason and it won't show any errors and such. Anyone have any clue what I'm doing wrong?

local childList = {}
local Min = 0
while true do
    function checkObject(obj)
    if (obj ~= script.Parent) and (obj.Name == "Breakable")  then
        Min = Min + 1
        table.insert(childList,1,obj) 
    else    if (obj.ClassName == "Model") or (obj == workspace) then
        local child = obj:GetChildren()
        for x = 1, #child do
                checkObject(child[x])
                wait()
            end
        wait()
        end
        wait()
        obj.ChildAdded:Connect(checkObject)
    end
    wait()
end
checkObject(workspace)
    local child = childList[Min]
    if (child ~= script.Parent) and (child.Name == "Breakable") then
        local dis = (child.Position-script.Parent.Position).magnitude
        if dis <= 200 then
            child.Anchored = false
            child.CanCollide = false
            table.remove(childList,Min)
            Min = Min - 1
            wait()
            end
            wait()
        end
    wait()
    end

Answer this question