How can I delete the children of a part?

im trying to make a flashtep, but it comes up with this error:
attempt to call missing method 'Destroy' of table

(script inside tool inside starterpack)
this is my code:

script.Parent.Activated:Connect(function()
	local char = script.Parent.Parent
	print(char.Name)
	
	for i,v in pairs(char:GetChildren()) do
		if v:IsA("Part") then
			v:Clone()
			local c = v:GetChildren()
			c:Destroy()
			v.Transparency = 0.4
			v.Color = Color3.fromRGB(0,0,0)
			v.CanCollide = false
			v.Anchored = true
			local p = Instance.new("Folder", workspace)
			v.Parent = p
		end
	end
end)
local c = v:GetChildren()
c:Destroy()

GetChildren returns a table, you are trying to Destroy a table.

Instead try something such as

for _,Child in v:GetChildren() do
	Child:Destroy()
end
1 Like

thanks, works perfectly

character limit

You can just do

part:ClearAllChildren()
2 Likes

Thanks, I forgot that existed :sweat_smile:

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.