Amount of part In area

Hello, dev forum!

I’m trying to find how much of a part is in an area. For reference, look at this image.

How would I find out how much exactly is in the area?

local Part = workspace.Part

print("Theres "..tostring(#workspace:GetPartsInPart(Part)).."other Parts inside the Part.")

That’s not exactly what I’m looking for; I’m looking for the percentage of the brick in the area.

Found it! Probably not the best solution.

if not Part:IsA'BasePart' then continue end
		local checkAmount = 1/9
		local total=0
		for i=0,1,checkAmount do
			local End = Part.Position + Vector3.new(0,0,Part.Size.X/2)
			local Start = Part.Position - Vector3.new(0,0,Part.Size.X/2)
			local checkPosition = Start:Lerp(End, i)
			if Main.Utility:pointInVolume(checkPosition, CFrame.new(areaPosition), areaSize) == true then
				total+=checkAmount
			end
		end

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.