How do I get the direction of an edge?

I tried to simplify the title as much as possible because it’s a bit complicated. I’m making a circle get chunks of it cut off it it is over an edge. The circle has a bunch of attachments as origins and directions for raycasts. Each attachment was coded to have a cframe that is pointed towards the origin of the part(but this is the problem).

Since the attachments are facing the part, the negative part subtracts chunks around it like a circle, but this isn’t how it should be. When it chops off a chunk the negative part should be is the same direction as the edge. How do I get the direction of the edge?

1 Like

Can you explain a little more about your setup here? Do attachment CFrames affect the result of CSG?

Yes. Every task.wait() it raycasts from every attachment with a length of 1(for now), and if the raycast is nil then it creates a part, and uses subtract async on the part.

I think I understand—so you’re using these attachments to sample wether or not to clip the circle with a negation block?

Can you share the code you’re using to do the positioning of that block currently?

Also, what is this going to be used for in the end? It seems like a difficult way to do things

Sounds like you could just run :inverse on the Cframe to flip its direction, then it would point away from the center and not towards it. I think that answers your question…

Yes. And the code is going to be for a blood pool that doesn’t float over edges.
if you have a better way pls tell me this is laggy

local part = workspace.Pool
while task.wait() do
	for i,v in pairs(part:GetChildren()) do
		if v:IsA("Attachment") then
			local rpm =
			rpm.FilterType = Enum.RaycastFilterType.Blacklist
			rpm.FilterDescendantsInstances = {part}
			local rayc = workspace:Raycast(v.WorldPosition,v.WorldCFrame.UpVector*-1,rpm)
			if not rayc then
				local part1 ="Part")
				part1.Size =,100,100)
				part1.Orientation = v.WorldOrientation
				part1.Position = v.WorldPosition + v.WorldCFrame.LookVector*-50
				local newpart = part:SubtractAsync({part1},Enum.CollisionFidelity.PreciseConvexDecomposition,Enum.RenderFidelity.Performance)
				newpart.Name = "Pool"
				newpart.Parent = workspace
				for j,x in pairs(part:GetChildren()) do
					if x:IsA("Attachment") then
						local cf = x.WorldCFrame
						x.Parent = newpart
						x.WorldCFrame = cf
				part = newpart

I can look into some other solutions, but how about a SurfaceGui on the part you’re landing on, and a ImageLabel with a blood texture on that Gui?

That would work for lots of cases, might be great depending on your level geometry. Wouldn’t be perfect but would probably look better than this approach generally.

Couldn’t you do some math using the part’s size and position along with the bloods size and position to determine where the edges of the part are and if the part goes over them and by what percent? It would be less dynamic because it only considers the bounding box, not the actual part, but would be cheaper on the server

I tried using surface gui’s but it doesn’t work with spheres, cylinders, or really anything.