Skip to content

Player

The player wrapper provides access to a connected player. Players are obtained via mc.players, world.players, or as event handler arguments.

Player extends Entity — all entity properties and methods are available on players. Only player-specific additions are listed here.

Metatable name: "player"

  • player.name (string) — Username. Read-only.
  • player.uuid (string) — UUID. Read-only.
  • player.displayName (string) — Read-only.
  • player.customName (string or nil)
  • player.isOp (boolean) — Operator status. Read-only.
  • player.ping (number) — Latency in ms. Read-only.
  • player.isFlying (boolean) — Read-only.
  • player.selectedSlot (number) — Hotbar slot 0–8. Read-only.
  • player.food (number)
  • player.saturation (number) — Read-only.
  • player.xpLevel (number) — Read-only.
  • player.xpProgress (number) — Progress to next level (0–1). Read-only.
  • player.gamemode (string) — "survival", "creative", "adventure", "spectator".
  • player.data (table) — Persistent per-player data. See Storage.

Entity methods inherited: raycast(), addEffect(), removeEffect(), hasEffect(), setOnFireFor(). damage() is overridden for players (always uses generic damage source, no source parameter).

Sends a chat message.

  • text (string) — Message text
player:sendMessage("Hello!")

Sends an action bar message.

  • text (string) — Message text
player:sendActionBar("&eHotbar message")

player:sendTitle({title, subtitle?, fadeIn?, stay?, fadeOut?})

Section titled “player:sendTitle({title, subtitle?, fadeIn?, stay?, fadeOut?})”

Sends a title. Two forms:

Positional form — fixed fade timing (20/60/20 ticks):

ParamTypeDescription
titlestringTitle text
subtitlestringSubtitle text
player:sendTitle("&cWarning", "&7Danger zone")

Table form — custom timing:

FieldTypeDefaultDescription
titlestring""Title text
subtitlestring""Subtitle text
fadeInnumber20Fade-in ticks
staynumber60Stay ticks
fadeOutnumber20Fade-out ticks
player:sendTitle({ title = "&aVictory!", subtitle = "&7You won!", fadeIn = 10, stay = 40 })

Teleports to coordinates.

  • x, y, z (number) — Target coordinates
  • world (string, optional) — Target world name (e.g. "minecraft:overworld")
player:teleport(0, 64, 0)
player:teleport(0, 64, 0, "minecraft:the_nether")

Restores health.

  • amount (number) — Health to restore
player:heal(20)

Kicks the player.

  • reason (string) — Kick message
player:kick("You have been kicked!")

Checks a permission node.

  • node (string) — Permission node
if player:hasPermission("myplugin.admin") then end

Plays a sound.

  • id (string) — Sound identifier
  • volume (number, default 1.0) — Volume
  • pitch (number, default 1.0) — Pitch
player:playSound("minecraft:entity.ender_dragon.growl", 1.0, 1.0)

Gives an item to the inventory. Accepts an ItemStack wrapper or an item ID string.

  • item (ItemStack or string) — Item to give, or item ID
  • count (number, optional) — Stack size (only with string ID)
player:give(mc.createItem("diamond", 1))
player:give("diamond", 16)

Sets an item in a slot.

  • slot (number) — Slot index
  • item (ItemStack or nil) — Item or nil to clear

Gets the item in a slot.

  • slot (number) — Slot index

Clears the inventory.

player:clear()

Each player has a per-player sidebar.

Creates or updates the sidebar. Auto-shows on first creation. Partial updates merge.

player.sidebar = {
title = "&6My Server",
lines = { "&aWelcome!", "", "&7Players: " .. mc.onlineCount }
}
player.sidebar = { title = "&6Updated Title" }
player.sidebar = { lines = { "Line 1", "Line 2" } }
player.sidebar = { visible = false }
player.sidebar = nil -- destroy

type: string

Current title. Assign to update.

type: table

Lines array (strings). Assign to replace all lines.

type: boolean

Whether shown. Read-only.

type: number

Number of lines. Read-only.

Sets a specific line (1‑indexed).

  • n (number) — Line index
  • text (string) — Line text

Shows the sidebar.

Hides the sidebar.

Destroys the sidebar permanently.

local sb = player.sidebar
sb.title = "Updated Title"
sb.lines = { "Line A", "Line B", "Line C" }
sb:setLine(2, "Modified Line B")
sb:hide() sb:show() sb:destroy()