# 難易度を変える（gameplay.setDifficulty）

> ゲームの難易度を変更します。

- カテゴリ：ゲームプレイ（gameplay）
- ブロック：ゲームの難易度を PEACEFUL に変更する
- URL：https://makecode.minecraft-okinawa.com/reference/gameplay/set-difficulty/
- Pythonでの名前：gameplay.set_difficulty
- 公式データ取得日：2026-11-13
- 動作確認：確認待ち

## JavaScript

```javascript
gameplay.setDifficulty(PEACEFUL)
```

## Python

```python
gameplay.set_difficulty(PEACEFUL)
```

## 引数

| 名前 | 値 | 意味 |
|---|---|---|
| difficulty | GameDifficulty | 新しい難易度 |

## 使用例

### Change it to normal, or even hard for a greater challenge!

```javascript
player.onChat("creeper", function () {
    gameplay.setDifficulty(EASY)
    mobs.spawn(mobs.monster(CREEPER), pos(0, 0, 0))
})
```

```python
def on_on_chat():
    gameplay.set_difficulty(EASY)
    mobs.spawn(mobs.monster(CREEPER), pos(0, 0, 0))
player.on_chat("creeper", on_on_chat)
```

## 出典

- [MakeCode for Minecraft 公式リファレンス（gameplay.setDifficulty）](https://minecraft.makecode.com/reference/gameplay/set-difficulty)

執筆：鈴木孝昌（現役プロジェクトマネージャー／マイクラカップ指導者）／運営：沖縄マイクラ部 プログラミングスクール「クロスウェーブ」（https://minecraft-okinawa.com/）