Region3 makes straight line

Currently I’m making a region3 script to play music when a player enters and leaves it. But I’ve run into an issue, after testing it and it not working, I decided to print the regions position and size. To where the position I believe is correct, although the Y and Z values are negatives for the size, and even turning them positive doesn’t make it what I want the size to be.

local RegionPart = ShallowEnd
local MinSize = RegionPart.Corner1.Position
local MaxSize = RegionPart.Corner2.Position
local EntireRegion = Region3.new(MinSize, MaxSize)
print(EntireRegion.CFrame.Position)
print(EntireRegion.Size)
local Region = workspace:FindPartsInRegion3WithWhiteList(EntireRegion, {workspace.MapItself}, 99999)

Does anyone know a fix to this?

1 Like

This may address your issue:

The order of the components matters. In your case, the location of Corner1 and Corner2 may be causing issues. I also believe the default Region3 constructor still only works with axis-aligned bounding boxes with zero orientation.

local part = workspace.Part
-- if the part is rotated, you may have problems, there is a Region3 module that supports rotations somewhere on the site
local min_p = part.Position - part.Size/2
local max_p = part.Position + part.Size/2
local region = Region3.new(min_p, max_p)

(Also, I see that your last line defines a variable named “Region”, but the method call returns an array of parts. It may or may not confuse you later on, this is just a heads up.)

1 Like