Skip to content
Untitled Sandbox - Developer Documentation

Npc

A character in your place that can walk, turn and speak, which you get from npc.find or npc.all.

Everything on the Instance page works on it too.

Events

arrivedEvent<(Npc)>

You listen to these with :connect, which the Event page covers.

Npc:user_id

method

Copies a user's appearance onto the NPC, or gives the ID it copies when you pass nothing. 0 is the default appearance.

Npc:user_id(user_id: number?) -> number
example
guide:user_id(12345)

Use it fordressing a guide or shopkeeper as a real player, such as the game's creator.

user_idoptionalThe platform user ID to copy, 0 for the default appearance. Omit it to get the current ID.

Npc:move_to

method

Makes the NPC walk to a position or an instance, at a speed you can choose.

Npc:move_to(target: vector | Instance, options: { … }?) -> Movement
example
local movement = guide:move_to(door, { speed = 8 })

Use it forguides that lead players around, guards on patrol, or villagers wandering the town.

targetA position, or an instance to walk to.
optionsoptionalThe walking speed.
Build a move_to callspeed
  • speed

    How fast the NPC moves in studs per second, which must be above 0 and is the place's walk speed by default.

Npc:teleport

method

Moves the NPC to a position or an instance at once, without walking.

Npc:teleport(target: vector | Instance) -> ()
example
guide:teleport(math3d.vector3.new(0, 0, 10))

Use it forputting a shopkeeper back in place, or moving an NPC between areas.

targetA position, or an instance to go to.

Npc:face

method

Turns the NPC so it faces a position or an instance.

Npc:face(target: vector | Instance) -> ()
example
guide:face(player.position)

Use it formaking a shopkeeper look at the player who is talking to them.

targetA position, or an instance to turn toward.

Npc:say

method

Shows a speech bubble with your text above the NPC.

Npc:say(text: string, options: { … }?) -> ()
example
guide:say("Follow me!", { duration = 3 })

Use it forgreetings, hints, or quest lines that NPCs say to players.

textWhat the NPC says, at most 1000 characters.
optionsoptionalHow long the Speech Bubble shows.
Build a say callduration
  • duration

    How many seconds the Speech Bubble shows, which by default depends on how long the text is.

From Instance

id, kind, name, parent, position, rotation, size, color, transparency, visible, can_collide, anchored, velocity, physics, prompt, touched, touch_ended, touching, interacted, seat, occupied, vacated, spawn, prefab, angular_velocity, mass, collision_group, center_of_mass, gravity_scale, linear_damping, angular_damping, sleeping, display_name, clickable, clicked, billboard, audience

↑ ↓ moveEnter openEsc close