Trying to detect if a parts inside of of a plot and dont want any corners outside of it so i tried making this
local function CheckCFrame(cf)
if not PlayerPlot then return false end
for i, v in ipairs(PlayerPlot.PlotArea:GetChildren()) do
local C1 = v.Size/2 + v.Position + Vector3.new(0,4,0)
local C2 = -v.Size/2 + v.Position
local PC1 = PlacementPart.Size/2 + PlacementPart.Position
local PC2 = -PlacementPart.Size/2 + PlacementPart.Position
Part1.Position = PC1
Part2.Position = PC2
local Check1 = PC1.X < C1.X and PC1.Y < C1.Y and PC1.Z < C1.Z
local Check2 = PC1.X > C2.X and PC1.Y > C2.Y and PC1.Z > C2.Z
local Check3 = PC2.X < C1.X and PC2.Y < C1.Y and PC2.Z < C1.Z
local Check4 = PC2.X > C2.X and PC2.Y > C2.Y and PC2.Z > C2.Z
if Check1 and Check2 and Check3 and Check4 then
print("Check")
else
print("failed", Check1, Check2, Check3, Check4)
end
end
return true
end
ofc it doesnt work but im wonder if theres a better way
There is a module named ZonePlus made by ForeverHD, which does exactly the same thing u wanna do but a lot easier to customise. I suggest you check it out.
for i, v in ipairs(Plot.Plot.PlotArea:GetChildren()) do
AreaPart.Size = v.Size + Vector3.new(0,Plot.PlotData.Height,0) - Vector3.new(0,v.Size.Y,0)
AreaPart.Position = v.Position + Vector3.new(0, AreaPart.Size.Y/2, 0) + Vector3.new(0,.5,0)
local TempTable = workspace:GetPartBoundsInBox(AreaPart.CFrame, AreaPart.Size)
if table.find(TempTable, Placementpart) then IsInBounds = true end
end
and it still happens if some of the part is in the area