Problem with Region3

I have a problem with my Region3s.

I have 2 Region3 working as a detector, however, the problem is that they only detect stuff when they’re facing a specific direction.
How/ why does this happen?

Code:


-- loop because yes
while wait() do
        -- Origin of the CFrames
    local RR = workspace.Dummy2.RR
    
        -- Max. /Min. CFrame for second Region3 (.Position added in line 27)
        local Region1Front = RR.CFrame * CFrame.new(-60, 0, 0)
    local Region1Back = RR.CFrame * CFrame.new(-70, -14, -1)
        
        -- Max. /Min. CFrame for second Region3 (.Position added in line 33)
    local Region2Front = RR.CFrame * CFrame.new(-10, 0, 0)
    local Region2Back = RR.CFrame * CFrame.new(-59, -14, -1)
    
        -- Update Region3 Max. /Min. Indicator's Position
    script.Parent.Parent.Model.Part1.Position = Region1Back.Position
    script.Parent.Parent.Model.Part2.Position = Region1Front.Position
    script.Parent.Parent.Model.Part3.Position = Region2Back.Position
    script.Parent.Parent.Model.Part4.Position = Region2Front.Position

        -- Regions
    local Region1 = Region3.new(Region1Front.Position, Region1Back.Position)
    local Region2 = Region3.new(Region2Front.Position, Region2Back.Position)
    
    for num, part in pairs(workspace:FindPartsInRegion3(Region1, workspace.BasePlates, 100000)) do
        print(part.Name, 'Region1')
    end
        
    for num, part in pairs(workspace:FindPartsInRegion3(Region2, workspace.BasePlates, 100000)) do
        print(part.Name, 'Region2')
    end
end

Blue and Black Parts are the indicators of the Max./ Min. of the Regions

Why not visualise the CFrames you’re giving? Region3 can’t be rotated and you’re giving it static values so it’s going to operate in world space. The first thing you want to do is understand where exactly the spatial cast is occurring over, so you could create a visualisation to see where things are going.

Specifically, create parts or a box using your RegionXY variables to see where they’re positioned.

3 Likes

It’s working now, thanks for your help!