The parts inside this box are the parts I want to clone.
I guess you can create part and then use this.
https://developer.roblox.com/en-us/api-reference/function/BasePart/GetTouchingParts
local array = parts:GetTouchingParts()
for i,v in ipairs(array) do
local clone = v:Clone()
end
But the best way is to find parts in region
cuz gettingtouching parts don’t work with disabled cancollide
You can use Region3 for this. Take the position and the amount of territory for this
local distanceX= 10
local distanceY = 20
local distanceZ = 30
local ignl = {} - ignore list
table.insert(ignl,part)
local min = part.Position - Vector3.new(DistanceX,DistanceY,DistanceZ)
local max = part.Position + Vector3.new(DistanceX,DistanceY,DistanceZ)
local region = Region3.new(min, max)
local parts = workspace:FindPartsInRegion3WithIgnoreList(region,ignl,1200) – 1200 - is limit of parts to check
for _,Part in pairs(parts) do
Part:Clone() – for Example
end
instead of the distance, you can specify the size of the part
Region3
's have been superseded by spatial query operations.
local Workspace = workspace
local Box = Workspace.Box
local Parts = Workspace:GetPartsInPart(Box)
for _, Part in ipairs(Parts) do
print(Part)
end