Inaccurate GetPartBoundsInRadius result

image

    local connection
	local tagList = {}
	connection = newRock.Touched:Once(function(hit)
		hitSound:Play()
		newRock.Anchored = true
		
		local hitRadius = 7
		local params = OverlapParams.new()
		params.FilterType = Enum.RaycastFilterType.Exclude
		params.FilterDescendantsInstances = {creature.Parent}
		params.MaxParts = 30
		local objectsInSpace = workspace:GetPartBoundsInRadius(newRock.Position, hitRadius, params)
		
		print(objectsInSpace)
		for i, part in pairs(objectsInSpace) do
			print("A")
			local taggedHum = part.Parent:FindFirstChild("Humanoid")
			if taggedHum and not tagList[taggedHum] then
				tagList[taggedHum] = true
				taggedHum:TakeDamage(25)
			end
		end
		table.clear(tagList)
		connection:Disconnect()
	end)

Whenever the newRock part hits something, it’s supposed to damage all Humans nearby.
Two things tend to happen, interchanging quite randomly:

  1. It prints out a good list of objectsInSpace, being 'LeftHand, Head, Handle, Handle, UpperRightArm etc. , along with (A) printed about 7 to 22 times or so.
    The Human gets damaged :white_check_mark:

  2. It prints out ‘Boulder’ (the name of the part) once or twice, with sometimes a Handle or Baseplate in it as well, never exceeding 5 A’s.
    The Human takes no damage :negative_squared_cross_mark:


Any reason as to why sometimes it doesn’t damage the human and other times it does?

probably because the rock is getting stopped by something unexpected

try creating an anchored part where the rock hits to see where its hitting

function debugPart(newRock)
  local part = Instance.new("Part", workspace)

  part.Size = Vector3.new(1,1,1)
  part.Position = newRock.Position
  part.Anchored = true
end

image

Hm, yea. Strangely enough the part spawns further than the newRock visually reaches. No idea what’s up with that. Any way to prevent it from happening?

(*) After adding a 0.2 second wait, and then anchoring and checking, it seems to be way more consistent. The visual effect however ends up in the ground (+ there’s a damage/hit delay) x_x
Featuring two different parts would probably work, but eh… isn’t there a cleaner way?