local partsHit = {}
-- listen for contact
explo.Hit:Connect(function(part, distance)
local parentModel = part.Parent
local car = parentModel:FindFirstAncestor("Cars")
if car then
local distanceFactor = math.clamp(1 - (distance / explo.BlastRadius) * 10, 0, maxDamage)
table.insert(partsHit, {part = part, damage = distanceFactor})
end
end)
print(partsHit)
PhysModule.DealDamage(partsHit)
Trying to get the partsHit table results in an empty table after the connection. I believe the issue is me trying to call for the table before the hit gets to add any parts to the table, but I do not know any way to get the table and its contents after everything has been added to it
Hopefully its something simple im missing, anyone have any ideas?
I have a seperate module script handling Damage and I would prefer to send only one large table of parts at a time instead of sending say 50 individual parts.
This is a very important part of my game and it needs to be performant.
I may be able to simply wait for all the parts, not the cleanest but if it works it works ig
This is not possible with events. The Hit event will fire for every individual part. Unless the damage is triggering other explosions, the performance improvement from using a table is miniscule if anything.
If you want to avoid using hit detection like that, you can create a sphere when the explosion occurs and utilize GetPartsInPart then delete the sphere. This will give you a table of all parts that would be hit by the explosion, assuming you match the sphere’s size with your explosion’s radius.