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

how to use getchildren to destroy parts?

while true do
local Doors = workspace:GetChildren()
for i = 1, #Doors do
if Doors.Name == "Door" then
Doors:Destroy()
wait(0.3)
end
wait(500)
end
end

I was testing ways to destroy stuff in workspace but it wont destroy my item

2 answers

What you're doing wrong is, you're just checking if the Children table's name is 'Door'

here's how you correctly do it :

if doors[i].Name == 'Door' then
doors[i]:Destroy()
end

You can't destroy a table. Doors is a table of parts, you need to call :Destroy() on each door.

while true do
	local Doors = workspace:GetChildren()
	for i = 1, #Doors do
		local door = Doors[i]
		if door.Name == "Door" then
			door:Destroy()
			wait(0.3)
		end
		wait(500)
	end
end

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