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

How to destroy all parts in a model when something touches it?

Asked by 9 years ago

I tried doing this:

parts=script.Parent:GetChildren()
parts.Touched:connect(Clean)

function Clean(Part)
      wait(4)
      parts:Destroy()
end

(the parts are within a model)

1 answer

Log in to vote
3
Answered by 9 years ago

Here we go.

For Loop

With the for loop, we can do this.

for i,v in pairs(script.Parent:GetChildren()) do
    wait()
    v.Touched:connect(function(hit)
        print("boom boom bam explosion destroys")
        script.Parent:Destroy()
    end)
end
0
That for loop doesn't quite fit in to this. Try showing him the link to the for pairs. woodengop 1134 — 9y
Ad

Answer this question