Back to 9Minecraft
Wiki 9Minecraft Wiki 9Minecraft
Skript Plugin Wiki › Guides › Trigger Actions When Players Break Blocks

Trigger Actions When Players Break Blocks

Using Block Break Events

Skript allows you to detect when players break blocks and respond with custom actions. This is useful for creating mining rewards, preventing certain blocks from breaking, or logging activity.

Setting Up a Block Break Handler

Create a .sk file with an event listener:

`

on block break:

if event-block is diamond ore:

give diamond to player

send "You mined a diamond!" to player

`

This code runs every time any player breaks a block. The if statement checks what type of block was broken.

Practical Examples

You can cancel the break, drop custom items, or apply effects:

`

on block break:

if player has permission "admin.nobreak":

cancel event

send "You cannot break blocks!" to player

`

Use cancel event to prevent the block from actually breaking. Reload your scripts with /skript reload all and test by breaking blocks in-game. The actions will trigger instantly.