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

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

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

✓ Accepted answer

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

1 comment

0

That for loop doesn't quite fit in to this. Try showing him the link to the for pairs.

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