PcoWSkbVqDnWTu_dm2ix
Collapse Sidebar

Hit

Fires when the Explosion hits a BasePart within its Explosion/BlastRadius. Returns the part hit along with the distance of the part from Explosion/Position.

Note that the effect of an Explosion is not disrupted by obstacles, this means parts shielded behind other parts will still be hit, even if the BasePart they are shielded behind is anchored.

This event will also fire when Explosion/BlastPressure is equal to zero. This means developers can program their own custom behavior for explosions by eliminating the explosion’s influence on BaseParts and Terrain.

Note that this event will fire for every BasePart hit. This means it can fire multiple times for the same player character (as the character Model is made up of multiple parts). For this reason when dealing custom damage using the Explosion.Hit event it’s recommended to implement a check to see if the character has already been hit by the Explosion.

Parameters

Name Type Default Description

The BasePart hit by the Explosion.

The distance of the hit from Explosion/Position.


Code Samples


Custom Explosion

This sample contains a simple function that creates a custom explosion. The custom explosion will not break joints as Explosion.DestroyJointRadiusPercent is equal to 0. This means Humanoids will not be instantly killed as their neck joints are broken. In this example explosion.BlastPressure is equal to zero so as not to apply force or damage terrain but this can be changed.

The Explosion.Hit event is used to listen for contact. Once contact has been made the code will look for the parent model of the BasePart hit by the explosion. If that model exists, hasn’t already been damaged and has a Humanoid in it damage will be applied based on distance from the explosion’s origin.