GetPartBoundsInRadius() does not return all part in radius

GetPartBoundsInRadius() does not return all part in radius

the script:

function module.getInRange(entityModel: Model, range: number, angle: number)
	local characterPosition = entityModel:GetPivot().Position
	local overlapParam = OverlapParams.new()
	overlapParam.MaxParts = 1000
	
	local allInBound = workspace:GetPartBoundsInRadius(characterPosition, range, overlapParam)

	local entityInRange = {}
	local forwardDirection = entityModel:GetPivot().LookVector

	local angleThreshold = math.cos(math.rad(angle / 2)) -- later

	-- tester part
	warn("All in bound:",allInBound)
	for _, v:BasePart in allInBound do
		local parentModel = v.Parent
		if parentModel.Name == "Tester" then
			v.BrickColor = BrickColor.new("Really red")
		end
	end
	
	return allInBound
end

Why does it not return all the part?

1 Like

Is the range number set correctly? Maybe you haven’t increased it enough. Try adding the 64 integer limit (18446744073709551615), that way you catch all needed parts, no matter the metric.

image

It’s not a integer the limit

Didn’t you try making the radius higher? That could be the issue since a script can’t just stop running out of the blue, without a breakpoint after some parts are counted

Radius is depending on ability i just pressed a different key that’s why

local pos = Vector3.new(295.4664306640625, -0.0036001205444335938, 80.34600067138672) local v = Instance.new("Part") v.Parent = workspace v.Position = pos  v.Anchored = true print(workspace:GetPartBoundsInRadius(pos, 100000 ))

when i ran this in the console it returned every single part except the one in that specific folder :sob:

You’re script is fine, I’ve tested it and only added this to not detect my character.

overlapParam.FilterType = Enum.RaycastFilterType.Exclude|
overlapParam.FilterDescendantsInstances = {entityModel}|

Could it be that your parts have the CanQuery Disabled? if so that’s what causing it to not detect them. So just Enable it again like this below.
image

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