How get all parts close to a bomb without lag

I want to make a bomb, and destroy all the close parts around it
How i can do it without to many lag?

I should make an explosion instance and set DestroyJointRadiusPercent to 0 and use Explosion.Hit?

Or is going to be better to do a for loop and put all parts in a table and every explosion loop trough their positions?

And if want buildings with physics, i should weld the parts with the clasic weld or use a custom code?

1 Like

Use physics first, only use scripts if you must. Explosion.Hit sounds like a good plan.

1 Like

You can use GetPartBoundsInRadius, which will return a table of parts in the radius. All you need to do is give it a CFrame (the bombs CFrame) and a magnitude (a number you want as the bombs range).

For buildings with physics, I’d use welds and whenever you use GetPartBoundsInRadius you can delete any welds inside the parts it returns.

1 Like

That sound more optimized, and after finding all the parts in the explotion, i could destroy his parented weld or use :GetConnectedParts() to find the weld if is not a child

1 Like

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