Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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?

1 comment

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

1 answer

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

1 comment

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.