Made a big brick that destroys certain parts it touches - I.E. a part with a specific name. It works wonders when destroying a players limbs and torso, but doesn't consistently work when destroying other parts; it may destroy a part near the player, or one the player is standing on, but it's inconsistent and never destroys the same parts upon contact when testing.
This is the script I have so far, are there any adjustments or alternative methods I could use to make the destruction more reliable?
-- lava brick script yay
local DB = script.Parent
function onTouched(hit)
local hum = hit.Parent:FindFirstChild("Humanoid")
if hit.Name == "destructable" or hit.Parent:FindFirstChild("Humanoid") then
print 'part found'
hit:Destroy()
end
end
DB.Touched:Connect(onTouched)
I have tried GetTouchingParts, but it requires parts to have collision enabled, and the main destruction brick has collisions off. A players legs also have collision disabled which makes it pointless.
I suppose it's also worth noting the brick is constantly moving across the X plane; I'm not sure if that would affect anything in terms of scripting.

2 comments
I'm not sure if this would do much in terms of its performance, it's just a shot in the dark so I'm only commenting. have you considered a region3?
I dabbled with it a little - although I'm not familiar with it so I'd need to learn more about it before I could use it.