Unsure if this is what you meant, but you can use the width, length and height of the part to determine the lowest, highest, furthest and closest points of where the lights could search. In this case if you need the parameters of the base plate, you’d have the Vector3 point given, and then using the width, length and height you can find all of its other corners.
local part = game.Workspace.Part
local corner1 = part.Position
local corner2 = Vector3.new(corner1.X, corner1.Y + part.Size.Y, corner1.Z)
local corner3 = Vector3.new(corner1.X + part.Size.X, corner1.Y, corner1.Z)
And then you can continue that for whichever other corners you need.
I’d recommend looking into this and this as they both go over part intersection thoroughly and in a more efficient manner.
Else-wise, you’d have to create a function which simply checks that all 3 of the Vector3 values are within those corner parameters. For example you’d check that the X is less than the X of corner 2 and more than the X of corner 1, which you’d then have to do for all 4 corners.
What exactly are you trying to do?( i dont understand) , can your provide a visual representation ( video, images etc.), you can do as @rabbiguy950 essentially said to find if a point is in a block, if you wanted to find if a position in a AABB or Axis-Aligned Bounding Box, meaning it’s without rotation of a part you can do this:
local function IsWithinObject(Object, Position) --Axis Aligned!!!
local Offset = 0
local minX, maxX = Object.Position.X - (Object.Size.X + Offset)/2 , Object.Position.X + (Object.Size.X + Offset)/2
local minZ, maxZ = Object.Position.Z - (Object.Size.Z + Offset)/2, Object.Position.Z +(Object.Size.Z + Offset)/2
local minY, maxY = Object.Position.Y - (Object.Size.Y + Offset)/2, Object.Position.Y +(Object.Size.Y + Offset)/2
if math.clamp(Position.X, minX, maxX) ~= (minX or maxX) and math.clamp(Position.Z, minZ, maxZ) ~= (minZ or maxZ) and math.clamp(Position.Z, minY, maxY) ~= (minY or maxY) then
return true
else
return false
end
end
But like i said this is only for AABB bounding boxes meaning you would have to apply orientation to the function. Also i would not advise going through every single vector ( including in a table) of a part as it can be expensive especially when a part is really large or without any sort of heap. Anyways there a probably multiple ways to solve your problem.
Yep This will only work on Cuboids, to find if a position is inside any shaped part you would probably have to use ray casting or some algorithm to figure out the bounds to compare positions( i am not sure what the OP is asking though). i don’t think there really is a easy way to solve the problem in this tread or one definite solution, but there are ways to go about it.
First you need to define the bounds using the corner method shown above, and then afterwards you’d randomly create the point as is:
local pointX = math.random(xMin, xMax)
local pointY = math.random(yMin, yMax)
local pointZ = math.random(zMin, zMax)
local point = Vector3.new(pointX, pointY, pointZ)