Skip to content

players.setNameTag

Shows or hides the name, health and armour above one player’s head, for everyone.

players.setNameTag(player: PlayerTarget, visible: boolean): Promise<ActionResult>
Name Type Description
player PlayerTarget The player, or their ID.
visible boolean false to hide the tag, true to show it again.

A promise of an ActionResult: applied once the server has set it, or rejected with player-not-found.

Hide undercover players.

gamemodes/my-mode.ts
import { commands, players } from "nativemp";
commands.register("undercover", async (player) => {
await players.setNameTag(player, false);
});

A captured Player keeps this effect bound to its connection across awaits; see Async handlers.