WorldRoot:GetPartBoundsInRadius() alternative to return attachments

G’day there, I was looking for a possible method I could use that functions identically to the worldroot :GetPartBoundsInRadius() func.

Because this function only works for baseparts, Im wondering if you guys have any ideas as to how I can return attachments instead.

local rParts = workspace:GetPartBoundsInRadius(Position,Settings.ExplosionRadius,gBreakParam)
			for i, cPart in pairs(rParts) do
				if i % 300 == 0 then wait() end
				if cPart.Name == gameRules.GlassName and cPart:IsA("Part") then
					local size = 0.8 * cPart.Size * (math.random(-10,10) / 10)
					BreakGlass(cPart,Position,Vector3.new(0.2,0.2,0.2))
					wait()
				elseif cPart:IsA("Attachment") then ...

where the function will be used^^

cheers

1 Like

assuming the attachments would be touching the parts in the bounds, couldn’t you just for a pairs loop and do:

 if v:FindFirstChildOfClass("Attachment") then
local attachment = v:FindFirstChildOfClass("Attachment")

That’s what I thought, but I was just hoping someone knew a more efficient way to do it since it’d be a lot of cycling.

just create a util module with that function, so your code doesn’t get messy and you can utilize it anywhere you want.