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

How is it possible to explode one part and then another?

Asked by 6 years ago

Alright, so I'm making a pinewood type of game and I tried doing this code:

game.Workspace.TenToZero.Value.Changed:connect(function()
if game.Workspace.TenToZero.Value.Value == true then
    while true do
        game.Workspace.Part.Anchored = false
        expa.Position = game.Workspace.Part
        expa.Parent = script.Parent.Position
        expa.BlastPressure = 9999999
        wait(0.4)
        end
    end
end)

I'm trying to make this explode one part and then go to another, but it doesn't work properly. Is there a way to fix this?

0
well if u used a table ( which has the parts in them ) and looped through the parts then it would blow them up one after the other iddash 45 — 6y

1 answer

Log in to vote
0
Answered by
fredfishy 833 Moderation Voter
6 years ago

Use a for loop with pairs.

for i, v in pairs(Workspace:GetChildren()) do
    if v:IsA("BasePart") then
        local e = Instance.new("Explosion")
        e.Position = v.Position
        e.BlastRadius = 10
        e.BlastPressure = 1e6

        e.Parent = Workspace
    end
end
0
This will only work for immediate children of Workspace. You'd need a slightly more complex script to explode all parts in all models. Let me know if this is the case. fredfishy 833 — 6y
Ad

Answer this question