Entity
An entity this script spawned or saw in an event. Methods raise once it is gone. alive reads false for one that died or despawned; after remove, or after its entityDeath handlers, even reading the handle raises.
Fields
entity.kind: EntityKind#entity.type: string#its key: "minecraft:zombie", a content mob key, an item key for items, "npc", "hologram"
entity.alive: boolean#false once dead or despawned
Methods
entity:position() -> (number, number, number)#Returns the entity's x, y, z.
entity:yaw() -> number#degrees
entity:teleport(x: number, y: number, z: number, yaw: number?, pitch: number?)#Moves the entity. A nil yaw or pitch keeps the current one.
entity:velocity() -> (number, number, number)#blocks per second
entity:setVelocity(x: number, y: number, z: number)#blocks per second
entity:remove()#Despawns the entity and frees its place in the 256-entity limit.
entity:setNametag(text: string?)#Shows a name above the entity; nil hides it.
entity:setInvisible(invisible: boolean)#Hides or shows the entity.
entity:setGlowing(glowing: boolean)#Turns the glowing outline on or off.
Seats this entity on another. Raises if either cannot take part, or if it is the same entity.
entity:dismount()#Gets this entity off whatever it rides.
entity:health() -> number#half-hearts; 0 for entities without health
entity:setHealth(health: number)#Sets health in half-hearts, capped at its maximum; 0 kills it. Raises if it has no health.
Hurts the entity by amount half-hearts, credited to attacker if given. Raises if it cannot be damaged. Returns whether the hit landed.
entity:setAi(enabled: boolean)#false stops scripted movement: moveTo and follow do nothing until it is turned back on.
entity:moveTo(x: number, y: number, z: number, speed: number?)#Walks to a point (mobs path-find; other entities glide straight there). speed is a multiplier, default 1. Stops any follow.
Keeps within distance blocks (default 2) of a player, until that player leaves. nil stops following
entity:setContent(content: string)#Display entities only: an item key for item displays, a block state for block displays, MiniMessage text for text displays.
entity:setLines(lines: string | { string })#Holograms only: replaces the text, one string per line (at most 16).