Is there a easier way to do this?

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

1 Like

you could use Reigon3 or the GetPartsBoundInPart function

2 Likes

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.

1 Like

I would create a part that represents the plot in 3D (completely transparent and CanQuery disabled) along with the GetPartsBoundInPart method.

Region3 does not work for a rotated plot.

1 Like

I tried doing this

	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

is this something i can use? i only see GetPartsBoundsInBox