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

My explosion doesn't destroy any parts how fix?

Asked by
ym5a 52
3 years ago
Edited 3 years ago
local lm = script.Parent:FindFirstChild("lightninMakers")
local function getHighTingz() 
    local Table = {}
    for i,v in pairs(game.Workspace:GetDescendants()) do
        if v:IsA("Part") then
            if v.Position.Y >= 50 and v:FindFirstAncestor("mapTIngz") == nil and v.Name ~= "stormtig" then
                table.insert(Table,(#Table+1),v)
            end
        end
    end
    return Table
end
local function getMetallicThings()
    --
end
for i = 0,math.random(1,20) do
    local cl = game.ReplicatedStorage.stormtig:Clone()
    cl.Parent = lm
end
local function floree(numb)
    return math.floor(numb + 0.5)
end
local function tweenaroni(p)
    local t = game:GetService("TweenService"):Create(p,TweenInfo.new(0.1,Enum.EasingStyle.Linear),{Transparency = 1})
    t:Play()
    t.Completed:connect(function()
        p:Remove()
    end)
end
local function ligamentationasmarianismistation(part)
    local points = {}
    local parts = {}
    local foldor = Instance.new("Folder")
    foldor.Name = "lll"
    foldor.Parent = workspace
    local raycastResult = workspace:Raycast(part,Vector3.new(0,-1000,0))
    if raycastResult then
        if raycastResult.Instance:FindFirstAncestor("mapTIngz") == nil and raycastResult.Instance:IsA("BasePart") then
            print(raycastResult.Instance)
            print(raycastResult.Instance.Parent)
            raycastResult.Instance:BreakJoints()
            local exp = Instance.new("Explosion")
            exp.BlastRadius = 5
            exp.BlastPressure = 20  --Explosion at the Raycast Instance position
            exp.Visible = false
            exp.Position = raycastResult.Instance.Position
            exp.Parent = workspace.Folder
            raycastResult.Instance.Anchored = false
        end
    end
    local roundedNumb = floree((part - raycastResult.Position).Magnitude /8)
    for i = 0, roundedNumb do
        local offset = Vector3.new(math.random(-5,5),math.random(-5,5),math.random(-5,5))
        if i == 0 or i == roundedNumb then
            offset = Vector3.new()
        end
        local lightBlock = game.ReplicatedStorage.lightningPart:Clone()
        local pos = part + (raycastResult.Position-part).Unit * i * (raycastResult.Position-part).Magnitude / roundedNumb 
        lightBlock.Position = pos + offset
        lightBlock.Parent = foldor
        local tog = pos+offset
        points[#points+1] = tog
        lightBlock.Touched:connect(function(h)
            if h.Parent:FindFirstChild("Humanoid") ~= nil then
                h:TakeDamage(100)
            end
        end)
    end
    for i = 1,#points do
        if points[i+1] ~= nil then
            local lin = game.ReplicatedStorage.lightningPart:Clone()
            lin.CFrame = CFrame.new((points[i]+points[i+1])/2,points[i+1])
            lin.Size = Vector3.new(.5,.5,(points[i]-points[i+1]).Magnitude)
            lin.Parent = foldor

        end
    end
    local exp = Instance.new("Explosion")
    exp.BlastPressure = 20
    exp.BlastRadius = 5
    exp.Position = points[#points] --The explosion at the last Point of lightning
    exp.DestroyJointRadiusPercent = 1
    exp.Parent = workspace.Folder
    wait(.1)

    for i,v in pairs(foldor:GetChildren()) do
        tweenaroni(v)
    end
    wait(.1)
    foldor:Remove()
end
while true do
    wait()
    local tingTable = getHighTingz()
    --spawn(function()
        for i,v in pairs(lm:GetChildren()) do
            if v:IsA("Part") then
                ligamentationasmarianismistation(v.Position)
            end
        end
    --end)

    for i,v in pairs(lm:GetChildren()) do
        spawn(function()
            wait(math.random(1,3))
            if v:IsA("Part") then 
                local n = math.random(1,20)
                if n ~= 20 then
                    print("Not chosen")
                    v.Position = Vector3.new(math.random(-254.663,253.99),v.Position.Y,math.random(-255.359,254.976))
                elseif n== 20 and #tingTable >= 1 then
                    print(#tingTable)
                    local chosen = tingTable[math.random(1,#tingTable)]
                    v.Position = Vector3.new(chosen.Position.X,v.Position.Y,chosen.Position.Z)
                    print(chosen)
                end
            end
        end)
    end
end
game.ServerScriptService.eventos.Event.Event:Connect(function(msg)
    if msg == "noLightning" then
        for i,v in pairs(lm:GetChildren()) do
            v:Remove()
        end
    end
end)

I've commented on the important parts So this is just a lightning storm script it makes one Invisible explosion at the raycast Instance and Breaks its joints and unanchors it then It makes a visible explosion at the last point of the lightning It pretty much just does nothing to the houses. What happens: https://gyazo.com/9788f1e4bb7fedfa2450f05db36a3c5b I've tried altering it a LOT but still pretty much nothing Please help After a bit it finally destroys some parts but they fall in slow Motion

Answer this question