TextLabel
Defined in: server/api.d.ts:7503
Server-created replicated world-space text label.
Extends
Section titled “Extends”ServerEntity
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new TextLabel(
id):TextLabel
Defined in: server/api.d.ts:7508
Creates a wrapper for an existing text label; use TextLabel.create to spawn one.
Parameters
Section titled “Parameters”number
Existing text-label network entity identifier.
Returns
Section titled “Returns”TextLabel
Methods
Section titled “Methods”attachTo()
Section titled “attachTo()”attachTo(
target,offset?,bone?):void
Defined in: server/api.d.ts:7645
Follows another live entity instead of staying at the label’s own position. It streams from where the target is, moves into its virtual world and is destroyed with it.
Parameters
Section titled “Parameters”target
Section titled “target”number | ServerEntity
The entity to follow, or its network id.
offset?
Section titled “offset?”Vector3 | { x: number; y: number; z: number; }
Where to draw relative to it, in world axes; the game decides the reference point (a player’s head, say) unless a bone is given.
string | null
A bone or socket of the target to follow every frame, at most 64 bytes; the offset counts from it. Omitted or null follows the entity.
Returns
Section titled “Returns”void
destroy()
Section titled “destroy()”destroy():
void
Defined in: server/api.d.ts:7569
Destroys this replicated label; stale wrappers no longer resolve afterward.
Returns
Section titled “Returns”void
detach()
Section titled “detach()”detach():
void
Defined in: server/api.d.ts:7622
Stops following an entity; the label returns to its own position.
Returns
Section titled “Returns”void
getAudience()
Section titled “getAudience()”getAudience():
object
Defined in: server/api.d.ts:7655
Who the label is for, with players as network ids. For reading: a connected player with no avatar right now has no id and is left out, though the label stays as set for them, so passing this to update() would drop them.
Returns
Section titled “Returns”object
hideForTarget
Section titled “hideForTarget”hideForTarget:
boolean
hideFrom
Section titled “hideFrom”hideFrom:
number[]
showTo
Section titled “showTo”showTo:
number[] |null
getOptions()
Section titled “getOptions()”getOptions():
TextLabelOptions
Defined in: server/api.d.ts:7650
The label’s current look and placement, in the shape update() takes. The audience is left out: see getAudience().
Returns
Section titled “Returns”setColor()
Section titled “setColor()”setColor(
colorOrR,g?,b?,a?):void
Defined in: server/api.d.ts:7631
Changes the label’s packed ARGB color from a Color or byte components.
Parameters
Section titled “Parameters”colorOrR
Section titled “colorOrR”number | Color
A Color, or the red byte (0-255) when passing components.
number
Green byte (0-255) when passing components.
number
Blue byte (0-255) when passing components.
number
Alpha byte (0-255) when passing components; defaults to 255.
Returns
Section titled “Returns”void
setDrawDistance()
Section titled “setDrawDistance()”setDrawDistance(
distance):void
Defined in: server/api.d.ts:7587
Changes how far away clients can render the label.
Parameters
Section titled “Parameters”distance
Section titled “distance”number
Maximum rendering distance in world units, clamped from 1 to 1000 metres’ worth.
Returns
Section titled “Returns”void
setFadeDistance()
Section titled “setFadeDistance()”setFadeDistance(
distance):void
Defined in: server/api.d.ts:7593
Changes where the label starts fading out.
Parameters
Section titled “Parameters”distance
Section titled “distance”number
Distance in world units where fading starts; 0 starts it at 75% of the draw distance.
Returns
Section titled “Returns”void
setFont()
Section titled “setFont()”setFont(
family):void
Defined in: server/api.d.ts:7611
Changes the label’s font. A viewer whose client never registered the family sees the game’s font.
Parameters
Section titled “Parameters”family
Section titled “family”string
A family viewers’ clients registered with Fonts.register, at most 64 bytes; empty is the game’s font.
Returns
Section titled “Returns”void
setFontSize()
Section titled “setFontSize()”setFontSize(
size):void
Defined in: server/api.d.ts:7581
Changes the rendered font size.
Parameters
Section titled “Parameters”number
Font size in pixels, clamped from 1 to 512.
Returns
Section titled “Returns”void
setMinDrawDistance()
Section titled “setMinDrawDistance()”setMinDrawDistance(
distance):void
Defined in: server/api.d.ts:7599
Changes how close the label stops drawing, so another can take over up close. It is still sent that close, so the swap has no gap; one at or past the draw distance never draws.
Parameters
Section titled “Parameters”distance
Section titled “distance”number
World units, clamped from 0 to 1000 metres’ worth; 0 draws from the camera out.
Returns
Section titled “Returns”void
setMinFadeDistance()
Section titled “setMinFadeDistance()”setMinFadeDistance(
distance):void
Defined in: server/api.d.ts:7605
Changes how far the label fades in from its min draw distance.
Parameters
Section titled “Parameters”distance
Section titled “distance”number
World units where the label is fully faded in; at or below the min draw distance it appears at once.
Returns
Section titled “Returns”void
setStyle()
Section titled “setStyle()”setStyle(
style):void
Defined in: server/api.d.ts:7617
Resets the outline, shadow and background to a preset.
Parameters
Section titled “Parameters”number
0 none, 1 shadow, 2 outline, 3 box; unsupported values are ignored.
Returns
Section titled “Returns”void
setText()
Section titled “setText()”setText(
text):void
Defined in: server/api.d.ts:7575
Changes the label’s displayed text.
Parameters
Section titled “Parameters”string
Replacement text replicated to clients; at most 1024 bytes.
Returns
Section titled “Returns”void
setVirtualWorld()
Section titled “setVirtualWorld()”setVirtualWorld(
world):void
Defined in: shared.d.ts:80
Moves this entity into another virtual world.
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”void
setVisibleFor()
Section titled “setVisibleFor()”setVisibleFor(
player,visible):void
Defined in: server/api.d.ts:7662
Shows or hides the label for one player. A hidden player’s client is never sent it; hideForTarget still applies.
Parameters
Section titled “Parameters”player
Section titled “player”number | Player
A connected player, or their network id.
visible
Section titled “visible”boolean
false adds them to hideFrom and takes them off showTo; true undoes both, adding them to showTo while it is set.
Returns
Section titled “Returns”void
setVisibleTo()
Section titled “setVisibleTo()”setVisibleTo(
player):void
Defined in: shared.d.ts:82
Restricts replication to one player’s connection, within the usual range and visibility checks; null lifts it.
Parameters
Section titled “Parameters”player
Section titled “player”Entity | null
Returns
Section titled “Returns”void
toString()
Section titled “toString()”toString():
string
Defined in: server/api.d.ts:7564
Formats this label for logging and debugging.
Returns
Section titled “Returns”string
Text containing the label ID and current text.
update()
Section titled “update()”update(
options):void
Defined in: server/api.d.ts:7637
Changes any part of the label at once. A bad key throws and changes nothing.
Parameters
Section titled “Parameters”options
Section titled “options”Only the keys given change; outline, shadow, background, showTo and hideFrom are replaced whole.
Returns
Section titled “Returns”void
create()
Section titled “create()”
staticcreate(x,y,z,text,fontSizeOrOptions?,drawDistance?,virtualWorld?):TextLabel
Defined in: server/api.d.ts:7675
Creates and replicates a world-space text label, up to the server-wide limit of 512. A bad option throws and creates nothing.
Parameters
Section titled “Parameters”number
World-space X coordinate.
number
World-space Y coordinate.
number
World-space Z coordinate.
string
Initial displayed text.
fontSizeOrOptions?
Section titled “fontSizeOrOptions?”number | TextLabelOptions
Look and placement, or (the older form) the font size from 1 to 512.
drawDistance?
Section titled “drawDistance?”number
Older form only: the draw distance in world units.
virtualWorld?
Section titled “virtualWorld?”number
Older form only: the virtual-world identifier.
Returns
Section titled “Returns”TextLabel
Handle for the newly created label.
Properties
Section titled “Properties”attachBone
Section titled “attachBone”
readonlyattachBone:string
Defined in: server/api.d.ts:7553
The bone or socket of its target it follows; empty follows the entity.
readonlycolor:number
Defined in: server/api.d.ts:7518
Current packed ARGB color.
drawDistance
Section titled “drawDistance”
readonlydrawDistance:number
Defined in: server/api.d.ts:7528
Current maximum rendering distance in world units.
fadeDistance
Section titled “fadeDistance”
readonlyfadeDistance:number
Defined in: server/api.d.ts:7533
Distance in world units where fading starts.
readonlyfont:string
Defined in: server/api.d.ts:7548
The font family it asks for; empty is the game’s font.
fontSize
Section titled “fontSize”
readonlyfontSize:number
Defined in: server/api.d.ts:7523
Current font size.
readonlyid:number
Defined in: shared.d.ts:65
Network id, stable for the entity’s lifetime.
minDrawDistance
Section titled “minDrawDistance”
readonlyminDrawDistance:number
Defined in: server/api.d.ts:7538
Distance in world units up to which the label does not draw.
minFadeDistance
Section titled “minFadeDistance”
readonlyminFadeDistance:number
Defined in: server/api.d.ts:7543
Distance in world units where the label is fully faded in.
position
Section titled “position”position:
Vector3
Defined in: shared.d.ts:67
World position. Read, call set(...), then assign back.
rotation
Section titled “rotation”rotation:
Vector3|Quaternion
Defined in: shared.d.ts:69
Reads as a quaternion; assignments also accept Euler angles in degrees.
readonlystate:StateBag
Defined in: shared.d.ts:71
This entity’s key/value state: the server writes it, and every client that can see the entity receives it. See StateBag.
readonlystyle:number
Defined in: server/api.d.ts:7558
The preset nearest the current look: 0 none, 1 shadow, 2 outline, 3 box.
readonlytext:string
Defined in: server/api.d.ts:7513
Current replicated label text.
virtualWorld
Section titled “virtualWorld”
readonlyvirtualWorld:number
Defined in: shared.d.ts:73
The virtual world this entity replicates in. Read-only: change it with setVirtualWorld on the server.