Region3 says its size is 0,0,0 and wont detect parts within it

So I am trying to get a list of parts/players within a Region3 but I am having trouble trying to create the region.

local regionidoneone = Vector3.new(workspace:WaitForChild(“PartOne”).Position)
local regionidonetwo = Vector3.new(workspace:WaitForChild(“PartTwo”).Position)
local regionidone = Region3.new(regionidoneone,regionidonetwo)
print(regionidone.Size)
for _,Part in pairs(game.Workspace:FindPartsInRegion3(regionidone,nil,500)) do
print(Part.name)
end

Output prints (0,0,0)

1 Like

What are the Positions of PartOne and PartTwo? Maybe try printing them out beforehand like in the example here: Region3 | Roblox Creator Documentation

It prints out: 30.869270324707, 26.500007629395, -54.558471679688 65.46656036377, -100.49999237061, -8.4859828948975

Those positions are correct

1 Like

All of the positions in position 1 have to be lower than all of the positions in position 2

For example:
5,5,5
10,10,10
Is a valid region3

5,5,10
10,10,5
Even though it covers the exact same area is not a valid region3, and will have a size of 5,5,0

If theyre all backwards like this:
10,10,10
5,5,5
It will have a size of 0,0,0

2 Likes

In response to your mining game issue

local function GetPlayersInMine(Region1,Region2)
    	local Players = game:GetService("Players"):GetPlayers()
    	local PlayersInMine = {}
    	for i = 1,#Players do
    		if Players[i].Character then
    			local HRP = Players[i].Character:FindFirstChild("HumanoidRootPart")
    			if HRP then
    				local HRPP = HRP.Position
    				local PartSize = Vector3.new(4,4,4)
    				local XRange = (PartSize.X * 9)/2
    				local YRange = (PartSize.Y * 30)/2
    				local ZRange = (PartSize.X * 12)/2 -- partsize * part amount  /2 because we want distance from center
    				
    				local Center = (Region1 + (Region2 - Region1)/ 2) 
    				-- grab the diffrence between vectors and then divide the diffrence to get the center

    				print(math.abs((HRPP.X - Center.X)),math.abs((HRPP.Y - Center.Y)),math.abs((HRPP.Z - Center.Z)))
    				print(XRange,YRange,ZRange)
    				-- your prints for testing 

    				if math.abs((HRPP.X - Center.X)) <= XRange then
    					if math.abs((HRPP.Y - Center.Y)) <= YRange then
    						if math.abs((HRPP.Z - Center.Z)) <= ZRange then
    							table.insert(PlayersInMine,Players[i])
    						end
    					end
    				end
    			end
    		end
    	end
    	return PlayersInMine
    end
2 Likes