Skip to content

Player

Inherits from: LivingEntity

Represents a player entity in the game, inheriting from LivingEntity and adding player-specific attributes and actions.

Fields

blockInteractionRange: number Read/Write

The maximum distance at which the player can interact with blocks.

gamemode: string Read/Write

The player's current game mode (e.g., "survival", "creative").

mainHandItem: Item|nil Read/Write

A copy of the item currently held in the player's main hand, or nil if the hand is empty.

permissionLevel: number Read-Only

The player's permission level, typically between 0 and 4. A value of 0 means no special permissions.

inventory: PlayerInventory Read-Only

A reference to the player’s inventory.

Methods

teleport(world: World, pos: Vec3, yaw: number|nil, pitch: number|nil) player: Player

Teleports the player to a specified location in the given world. If yaw or pitch are not provided, the player's current rotation is used.

Example: Teleport with direction

local player = spell.owner
local destination = Vec3:new(100, 64, 100)
player:teleport(player.world, destination, 90, 45)  -- Teleports the player facing west and looking slightly down

Example: Teleport using current rotation

player:teleport(player.world, destination)  -- Teleports the player with current yaw and pitch

Parameters

Name Type Description
world World The world to teleport the player to.
pos Vec3 The target position.
yaw number|nil Optional yaw angle in degrees. Defaults to the player’s current yaw.
pitch number|nil Optional pitch angle in degrees. Defaults to the player’s current pitch.

Returns

  • Player — player A reference to the player after teleportation.