FindPartsInRegion3() doesn't work!

Hey there!

Here is my problem, I need to make a region3 and to get the touching parts to know if the character is inside the region.

So I made two parts (p1 and p2):

And I need a whitelist which is the Character descendants.

So this is my sample of code:

local parts = Workspace:FindPartsInRegion3WithWhiteList(region, char:GetDescendants(), 20)
	print(parts)
	if #parts > 0 then
		return true
	else
		return false
	end

As you can see, I put 20 as the third argument (max number of returned parts) but in fact, I only need one to know if the character is inside the region or not but I put 20 for the test.
My whitelist is the Character’s descendants.
So when I run the game, it prints 0 and returns false even if I’m between the two parts.
So I thought the problem comes from my whitelist, but even with this code, it prints 0:

print(#workspace:FindPartsInRegion3(Region3.new(workspace.dunkZone.p1.Position, workspace.dunkZone.p2.Position), nil, math.huge))

So finally, I thought the problem comes from my Region3 but I build it with two “Diagonal positions”. So I tried to see where is my Region3:

Workspace:WaitForChild("Terrain"):FillRegion(Region3.new(p1, p2), 1, Enum.Material.Water)

Then, when I run the game, my Roblox Studio just crashed.
So I don’t know what’s going on. I retried and it crashed again.
I think the problem comes from my Region3.
Doesn’t anyone have an idea?

Any help would be appreciated.

The only issue that I could really see is that your region variable is defined incorrectly, you should be getting a Min & Max value of the specific Region you’re attempting to search for

1 Like

I used to have a similar problem with region3, try using the min and max values:

     local region = Region3.new(
          Vector3.new(math.min(r1.X, r2.X), math.min(r1.Y, r2.Y), math.min(r1.Z, r2.Z),
          Vector3.new(math.max(r1.X, r2.X), math.max(r1.Y, r2.Y), math.max(r1.Z, r2.Z)
     )
5 Likes

Oh thank you! My problem is solved. Have a good day!

1 Like