> For the complete documentation index, see [llms.txt](https://docs.easy.gg/scripting/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.easy.gg/scripting/bedwars-scripting/events/weaponswing.md).

# WeaponSwing

Example usage:

```lua
Events.WeaponSwing(function(event)
    if (event.weapon == ItemType.LASER_SWORD) then
        ItemService.dropItem(ItemType.COSMIC_LUCKY_BLOCK, event.player:getEntity():getPosition())
    end
end)
```

### Parameters

#### player: [Player](/scripting/bedwars-scripting/objects/player.md)

The player that is swinging the weapon.

#### weapon: [ItemType](/scripting/bedwars-scripting/types/itemtype.md)

The ItemType of the weapon being swung.

#### hitEntity: [Entity](/scripting/bedwars-scripting/objects/entity.md) | nil

The entity that was hit by the sword swing (may not exist if the swing missed).

#### cancelled: bool <mark style="color:yellow;">\[modifiable]</mark>

If set to true, the weapon swing will be cancelled.
