# How would i get a area and check if a position is within that area?

Basically trying to find if a position is in a area, but without a part
Like i got the size and position of the area, just cant think on how i would find if a position is in or out of that area

Compare X, Y & Z values to that of the ones you’d use to create a Region3.

how would i get the values to create the region3 though

Region3 supports arguments for minimum vector and maximum vector, these are the corners of your newly created Region3. You’d then compare the coordinates by checking if the X, Y & Z axis are within range between the two points.

well is there a method to getting corners of something?

You create the corners. Use Vector3.new

yeah but where im using the area is already a pre existing thing, is there still a viable method?

Make parts that represent the corners of your region and position them to those said corners, copy their positions and put them in the Vector3 values (or you can just stick to Part.Position). With this information, you can use the provided function I have written to check if a point is in range of two vectors.

``````local minimumVector = Vector3.new(10, 10, 10)
local maximumVector = Vector3.new(-10, -10, -10)

local function checkInRange(point: Vector3, minimum: Vector3, maximum: Vector3): boolean
local x0, y0, z0 = point.X, point.Y, point.Z
local x1, y1, z1 = minimum.X, minimum.Y, minimum.Z
local x2, y2, z2 = maximum.X, maximum.Y, maximum.Z
return x0 < x2 and y0 < y2 and z0 < z2 and x0 > x1 and y0 > y1 and z0 > z1
end

checkInRange(Vector3.zero, minimumVector, maximumVector) --> true
checkInRange(Vector3.new(20, 0, 0), minimumVector, maximumVector) --> false
``````

i get the region and corners thing, but im only making said area off of size and position and dont know if its possible to get corners from only 2 vectors, a size and a position (at the middle of the area)

Yes, use size & position to calculate the corner. You just add half the size to the position and an inverse of that half to another position variable. With that, you’ll have both corners stored under a variable.

1 Like

Yep this worked (Character limit)