player class
player.name
function player.name() endReturns the player's name. Returns an empty string if the name isn't available.
Returns
- string: The player's name.
player.position
function player.position() endReturns the player's position in floating point coordinates. Returns 0, 0, 0 if the position isn't available.
Returns
- number: x The x coordinate.
- number: y The y coordinate.
- number: z The z coordinate.
player.rotation
function player.rotation() endReturns the player's rotation as a table with x and y fields. Returns {x = 0, y = 0} if the rotation isn't available.
Returns
- Vector2: The player's rotation.
player.dimension
function player.dimension() endReturns the player's dimension. Returns "unknown" if the dimension isn't available.
Returns
- string: The player's dimension.
player.velocity
function player.velocity() endReturns the player's velocity. Returns 0, 0, 0 if velocity isn't available.
Returns
- number: x The x velocity.
- number: y The y velocity.
- number: z The z velocity.
player.speed
function player.speed() endReturns the player's horizontal movement speed.
Returns
- number: The player's horizontal speed.
player.health
function player.health() endReturns the player's health. Returns -1 if health isn't available.
Returns
- number: health The player's health.
player.hunger
function player.hunger() endReturns the player's hunger. Returns -1 if hunger isn't available.
Returns
- number: hunger The player's hunger.
player.saturation
function player.saturation() endReturns the player's saturation.
Returns
- number: saturation The player's saturation.
player.hurtTime
function player.hurtTime() endReturns ticks since the player was last hurt.
Returns
- number: hurtTime The player's hurt time.
player.grounded
function player.grounded() endReturns true if the player is on the ground. Returns false if the player isn't available.
Returns
- boolean: True if the player is on the ground.
player.gamemode
function player.gamemode() endReturns the player's gamemode as a number. 0 = survival, 1 = creative, 2 = adventure, 3 = spectator.
Returns
- number: The player's gamemode.
player.armor
function player.armor() endReturns a table of armor piece objects. If armor is unavailable or an armor piece doesn't exist, all parameters are -1 except name, which is "empty".
Returns
- table: The table of armor piece objects.
player.offhand
function player.offhand() endReturns a table containing offhand item data. If the offhand item is unavailable or doesn't exist, all parameters are -1 except name, which is "empty".
Returns
- table: The table of offhand item data.
player.mainhand
function player.mainhand() endReturns a table containing mainhand item data. If the mainhand item is unavailable or doesn't exist, all parameters are -1 except name, which is "empty".
Returns
- table: The table of mainhand item data.
player.selectedSlot
function player.selectedSlot() endReturns the selected hotbar slot.
Returns
- number: The selected slot index.
player.effects
function player.effects() endReturns a table of active effects. Each effect has id, amplifier, and duration fields.
Returns
- table[]: The active effects.
player.say
function player.say(message) endMakes the player say something in chat.
Parameters
message: string: The message that you will say.
Returns
- nil:
player.executeCommand
function player.executeCommand(command) endExecutes a server command.
Parameters
command: string: The command without '/'.
Returns
- nil:
Reference: player.lua