Fire projectile hits block event||doc135533

September 20, 2022


  • The class to which the function belongs:Entity


This event is fired when a solid object fires a projectile that hits a block.


  • Only triggers the hit event when the projectile's properties are set to hit a block will only take effect.


The context content of the event

name type Description
obj1 Entity the object instance that fires the projectile
pos Vector3 block coordinates
missile Missile projectile example

Code Samples

On the server side of the entity templatemount script, register when an entity object of this type fires a projectile that hits a blockCallback, remove the hit block

Trigger.RegisterHandler(this:cfg(), "HIT_BLOCK", function(context)
    local from = context.obj1
    local blockPos = context.pos
    local map =             --Get the current object location map
    map:removeBlock(blockPos)        --Remove blocks based on the coordinates of the hit block