Region3 detects part which is not inside of region3

Theres a region3 every 2 frames at the camera’s position that checks for a lavapart. If a lavapart was found it enables the gui.

For some reason a region3 detects a part which is totally not inside of the region3 and i have no idea why this happens.

Is there a way to fix this?

1 Like

Show us your script so we can see, your probably making the region3 too big.

Really relevant. Read this reply to a similar problem:

Use a Region3 to check which parts may be in an area and then use another algorithm to double-check.

If you only need to check if a point is occupied by something (which looks like what you’re trying to do!), I wrote a function for that here:

EDIT: I edited the function a bit so that it returns a list of parts that are on the point. This should be useful for your usecase (checking if the camera is submerged in lava).

local function getPartsInPoint(p)
	-- Fudge the region by a bit to avoid the edgecase you saw in OP.
	local region =, 1, 1),, 1, 1))
	local possible = workspace:FindPartsInRegion3(region, 100)
	-- Broadphase: The region is bigger than the point and the region is empty. 
	-- Therefore, there must be nothing in this point.
	if #possible == 0 then return {} end
	-- Test each part in the region via raycast.
	-- FindPartsInRegion3 has a limit of 100 parts, though.
	-- If that point in the map is very, *very* dense with parts, then some parts won't be
	-- included in the Region3. You can fix this by doing more Region3 
	-- calls using FindPartsInRegion3WithIgnoreList (with the ignore list
	-- being the parts we're found so far) until no more parts can be found.
	local inPoint = {}
	for _, part in next, possible do
		-- Raycast to the center of the part.
		local ray =, part.Position-p)
		-- If we don't hit the part, then the point must be inside of the part.
		if next(workspace:FindPartOnRayWithWhitelist(ray, {part})) == nil then
			table.insert(inPoint, part)
	return inPoint

PS: I’m happy that you managed to apply most of my answer from a while ago to your problem :smiley:

1 Like

I have edited a script that i found somewhere a littlebit and it works without using rays / region3’s.

function isInRegion3(region, point)
    local relative = (region.CFrame:PointToObjectSpace(point) - region.CFrame:PointToObjectSpace(region.Position)) / region.Size
    return -0.5 <= relative.X and relative.X <= 0.5
       and -0.5 <= relative.Y and relative.Y <= 0.5
       and -0.5 <= relative.Z and relative.Z <= 0.5

Fair! The original script was designed to accommodate all part types (wedges, spheres, cylinders) and convex meshes. If you’re only worried about boxy parts, then that’s a fine optimization to use.

You’ll still need to use Region3s to get the parts close to a point, though. Unless you’re fine with iterating through all the lava parts every frame (totally OK if there’s only a few).

Reading your function again, I don’t see how you’d actually work this into what you’re doing. You’re checking if a point is inside a Region3, but why? I thought you want to check if a point is inside a lava part?

1 Like

I only have to check if the camera’s position is inside of the lava. So there’s no need to worry about wedges / etc.