Touched region3 doesn´t work[SOLVED]

  1. What do I want to achieve? I want to detect when something anchored is touching a part

  2. What is the issue? For some reasons, the touched doesn´t work, only when isn´t anchored.

  3. What solutions have I tried so far? I tried using region3 but it doesn´t work too.

local part = script.Parent

local region = Region3.new(part.Position - part.Size/2, part.Position + part.Size/2)

while wait(1) do
	print("BUCLE")
	local parts = workspace:FindPartsInRegion3(region)
	for i, part in pairs(parts) do
		local grab = part.Parent.Parent
		local bonesdamage = part:FindFirstChild("Bones")
	    if grab.Name == "BlockToDetect" and bonesdamage then
			print("Detectected")
			local bDamage = bonesdamage.Value
			local health = script.Parent.Health--In this part the script quit life from a block when it detect the block touch it
			health.Value = health.Value - bDamage
			print(health.Value)
		end
	end
end

Your code for getting the touching parts in region3 is correct so should be working.
I would suggest adding the line

print(parts)

under the FindPartsInRegion3 line and that will output everything that’s touching the part for you to analyse. It could be a coding error in your loop that is causing you the issue.
One other thing, it doesn’t make a huge difference but you should use ipairs for the loop since FindPartsInRegion3 returns an array not a dictionary.

1 Like

Thanks I will do that, maybe the while has an error

Hey!, i just move the script to another part and now works but i don´t know WHY xD(The parts are almost identical, except the color)