Region3 issues, not detecting the parts the way I want it to

I am trying to make a command that clears parts that are outside of the plot, and sooner or later once this command seems to be working fine then I’ll make it completely automatic to mitigate glitches.

Now, the issue I’m having here is either this script detects no parts in the Region3 (currently) or it detects all of the parts, depending on how I’ve adjusted the script. It never runs the way I want it to; I’m not sure why this is, as I’ve dealt with Region3s before.

					if cmdArgs[1] == "cop" or cmdArgs[1] == "clearoutsideparts" then -- Don't worry about this.
						if plr:FindFirstChild("SavingPlot") then -- Don't worry about this.
							display("command failed; player is currently saving / loading")
						local pba = workspace:FindFirstChild("Private Building Areas")
						local plot = pba:FindFirstChild(plr.Name .. "BuildArea")
						local hmr = plr.Character:FindFirstChild("HumanoidRootPart")
						if plot == nil then -- Don't worry about this except for "else".
							display("plot area not created")
							local min = ( *, -plot.Size.y/2, -plot.Size.z/2)).Position
							local max = ( *, plot.Size.y/2, plot.Size.z/2)).Position
							local PlotRegion =,max)
							local PartsInRegion3 = workspace:FindPartsInRegion3(PlotRegion, nil, 4096)
							for _,v in pairs(PartsInRegion3) do
							for _,v in pairs(plot:GetDescendants()) do
								if v:IsA("BasePart") then
									if table.find(PartsInRegion3, v) then
										print("Found part: "..v.Name)
									elseif not table.find(PartsInRegion3, v) then
										print("Found outside part: "..v.Name)
  00:38:43.662  LainnascusBuildArea  -  Server - LCSMain:1684
  00:38:43.662  Baseplate  -  Server - LCSMain:1684
  00:38:43.662   ▶ Found outside part: Part (x2)  -  Server - LCSMain:1692

Any form of help would be strongly appreciated.

If it’s not detecting the parts, it might be the position being wrong.

local min = ( *, -plot.Size.y/2, -plot.Size.z/2)).Position
local max = ( *, plot.Size.y/2, plot.Size.z/2)).Position

Try spawning a part at the 2 positions to visualize the Region3 box.
Seeing that you are using size to get the 2 corners
(I don’t know any better way to get the corners btw), maybe the plot basepart orientation is the problem.

Personally, I wudn’t use roblox’s default region over anything better. n this case, I use ZonesPlus.

1 Like

I’ll look into this, if it works fine then I’ll mark this done.

It turns out that the Y axis of min and max are somehow wrong, but, it’s fixed now along with other mitigations. Thanks for trying to help anyway, I’ll probably use that API in the future too.

1 Like
local min = plot.Position - plot.Size/2
local max = plot.Position + plot.Size/2
1 Like