Problems With Region3

Hello everyone, good morning.

I currently need to create a region3 to detect players inside that area. I am having a problem tho. The region is not being correctly made. So I am trying to create a region between these two parts:
https://gyazo.com/8dbf770d2eea64c23a724095f52ceb80
And here is the code:

local region3 = Region3.new(workspace:WaitForChild("rg1").Position, workspace:WaitForChild("rg2").Position)

The problem is that when I went inside the area the region was not detecting me in it. So I decided to “visualize” the region3 by creating a part with the region’s CFrame and Size. Here is the code:

local region3 = Region3.new(workspace:WaitForChild("rg1").Position, workspace:WaitForChild("rg2").Position)
local regionVisualizer = Instance.new("Part")
regionVisualizer.Name = "rV"
regionVisualizer.Anchored = true
regionVisualizer.Size = region3.Size
regionVisualizer.CFrame = region3.CFrame
regionVisualizer.Parent = workspace

Here is what I saw:
https://gyazo.com/f45f36cd96379c6c5dbead8fecaf9976
I am really confused right now. I am not sure what may be causing the problem.

1 Like
local rg1 = game.Workspace:WaitForChild("rg1").Position
local rg2 = game.Workspace:WaitForChild("rg2").Position
local region3 = Region3.new(
     Vector3.new(math.min(rg1.X, rg2.X), math.min(rg1.Y, rg2.Y), math.min(rg1.Z, rg2.Z))
     Vector3.new(math.max(rg1.X, rg2.X), math.max(rg1.Y, rg2.Y), math.max(rg1.Z, rg2.Z))
)

The first parameter of the Region3 constructor wants the smallest X, Y, and Z components out of both Vector3 positions and the second parameter wants the biggest X, Y, and Z components out of both Vector3 positions.

4 Likes