run Chat Command

Runs a chat command in your code that was already created using ||player:on chat command||.

player.runChatCommand("jump");

Parameters

  • command: the chat command to run, like: “jump”.

Example

Let’s say you have a chat command in your project that makes your agent move forward and place a block:

player.onChat("placeforward", function () {
        agent.move(FORWARD, 1);
        agent.place(BACK);
});

You can reuse this chat command in other parts of your code to have your agent build a row:

player.onChat("row", function () {
    agent.teleportToPlayer();
    for (let i = 0; i < 5; i++) {
        player.runChatCommand("placeforward");
    }
});

See Also

||player:run chat command with args||, ||player:on chat command||