Guide 1 Docs 2 Reference 3
15

Npc type

A player-shaped entity every client from 1.8 sees, from world.npc; it can walk, talk, hold items, wear armour and ride.

Functions 10

npc:look_at(pos: Vec3)

Where it stands; live, so setting it moves the NPC. A riding NPC reads the seat's position. Partial writes preserve other angles; nil after removal. Bodies have no roll. Turns head and body toward a point.

npc:swing()

Plays the arm swing animation.

npc:hold(item: (ItemSpec | false)?)

Puts an item in the main hand; nil or false empties it. An error on an unknown item.

npc:say(text: Text, color: Ink?)

Sends a chat line "<name> ..." to the room, or just the words for an NPC with no name.

npc:walk(opts: { path: { Vec3 }, speed: number?, loop: boolean? }?)

Walks the points by itself, facing where it goes; nil stops it.

npc:wear(pieces: Worn)

Puts armour on it, head first; each piece is an item.

npc:ride(thing: MountTarget, opts: { seat: number? }?) → boolean

Sits in a seat as player:ride does, and never drives; false when somebody sits there.

npc:dismount()

Gets off where it sits; set at after it to put it somewhere else.

npc:move(at: Vec3, rotation: BodyRotation?)

Removes the NPC. Sets position and optional rotation together.

npc:destroy()

Fields 5