The part is being moved automaticly in another script aswell as a script is activated in the part to check for the colliding parts. But this only works for cancollide being true. I have used the following ways without success:


local filter = true
local destroyableitems = {""}

script.Parent.Changed:connect(
	function()
	local theparts = script.Parent:GetTouchingParts()
	for i=1,#theparts do
		if filter then
			local destroyable = false
			for i2=1,#destroyableitems do
				if theparts[i].Name == destroyableitems[i2] then
					destroyable = true
					break
				end
			end
			if destroyable then
				theparts[i]:Destroy()
			end
		else
			theparts[i]:Destroy()
		end
		
	end
	
	
end)

and

script.Parent.Touched:connect(function(part)
	part:Destroy()
end)

3 comments

0

You can try FindPartsInRegion3, but that'll only work if your part isn't rotated.

0

Thank you I will try that

0

Your suggestion works perfectly.