How to use OverlapParams for bombs?

Hello, I am making a bomb. I want everyone inside that bomb to be affected however my previous method was to use .Touched and it didn’t really work well for multiple entities but OverlapParams have came out since then and now I can finally have one bomb affect multiple entities

I can’t seem to really understand how this new feature works, currently I have an “Unable to cast value to Object” on line ExplosionOverlapParams.FilterDescendantsInstances = {damagetaker}

I tried looking at the raycast equivalent to this but It’s just so different and there isn’t a lot of documentation for this.

local PhysicsService = game:GetService("PhysicsService")
local ExplosionOriginal = game.ReplicatedStorage.Explosion:Clone()
damagetaker = "DamageTaker"
PhysicsService:RegisterCollisionGroup(damagetaker)

local ExplosionOverlapParams = OverlapParams.new()
	ExplosionOverlapParams.FilterDescendantsInstances = {damagetaker}
	ExplosionOverlapParams.FilterType = Enum.RaycastFilterType.Include

NewExplosion.Touched:Connect(function(hit)
		--if touched then return end

		if hit.CollisionGroup == damagetaker then
			--touched = true
			if hit.Parent.Health then
				hit.Parent.Health.Value -= DamageCount
			end
		end
	end)
	
	local ExplosionHitbox = workspace:GetPartBoundsInBox(NewExplosion.CFrame, NewExplosion.Size, ExplosionOverlapParams)
	
	print(ExplosionHitbox)

If I am missing details please tell me because sometimes my questions get closed for being vague, also I am not using humanoids here I am using punching bag-like models

1 Like

I wouldn’t use .Touched but the reason you are having the error is because you are trying to find the descendants of a string which doesn’t make sense. Add the following:

local characters = {}
for i, plr  in ipairs(game.Players:GetPlayers()) do
	if plr.Character then
		table.insert(characters, plr.Character)
	end
end

and replace the line with:


ExplosionOverlapParams.FilterDescendantsInstances = {characters}

The last part of the question says that im not using other players as targets I am using punching bags made out of simple parts and with their own Collision group I have made

My bad, get rid of the i,plr loop and inside of the variable “character” put your punching bag models in there.

I want to have the entire collision group so that different types of hittable objects in the same collsion group will all count