# コマンドを実行する（player.execute）

> 現在のプレイヤーとしてゲームのコマンドを実行します。

- カテゴリ：プレイヤー（player）
- ブロック：コマンド "say hi" を 実行する
- URL：https://makecode.minecraft-okinawa.com/reference/player/execute/
- 公式データ取得日：2026-11-13
- 動作確認：確認待ち

## JavaScript

```javascript
player.execute("say hi")
```

## Python

```python
player.execute("say hi")
```

## 引数

| 名前 | 値 | 意味 |
|---|---|---|
| command | 文字列 | 実行するスラッシュコマンド（先頭に``/``を入れる必要はありません）。たとえば：「say Hi!」 |

## 使用例

### 全てのプレーヤーを、あなたのいる位置にテレポートさせるスラッシュコマンドを実行する。

```javascript
player.execute("tp @a ~ ~ ~");
```

```python
player.execute("tp @a ~ ~ ~")
```

## 出典

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

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