Reference API Roblox

Engine API

Website

Related

Reference API Roblox

TextService

Service internally responsible for handling the display of text.

This class is not replicated. Its interface does not cross the network boundary.
This class is not creatable. Instances of this class cannot be created with Instance.new.
This class is a service. It is a singleton that may be acquired with GetService.
Tags: [NotCreatable, Service, NotReplicated]

Member index 8

HistoryMember
607FilterAndTranslateStringAsync(stringToFilter: string, fromUserId: int64, targetLocales: Array, textContext: TextFilterContext = PrivateChat): TextFilterTranslatedResult
607FilterStringAsync(stringToFilter: string, fromUserId: int64, textContext: TextFilterContext = PrivateChat): TextFilterResult
645GetFamilyInfoAsync(assetId: ContentId): Dictionary
552GetFontMemoryData(): Dictionary
529GetTextBoundsAsync(params: GetTextBoundsParams): Vector2
462GetTextSize(string: string, fontSize: int, font: Font, frameSize: Vector2): Vector2
647GetTextSizeOffsetAsync(fontSize: int, font: Font): float
573SetResolutionScale(scale: float): null
inherited from Instance
553Archivable: bool
670Capabilities: SecurityCapabilities
553Name: string
553Parent: Instance
702PredictionMode: PredictionMode
670Sandboxed: bool
680UniqueId: UniqueId
576AddTag(tag: string): null
573ClearAllChildren(): null
462Clone(): Instance
573Destroy(): null
486FindFirstAncestor(name: string): Instance
486FindFirstAncestorOfClass(className: string): Instance
486FindFirstAncestorWhichIsA(className: string): Instance
486FindFirstChild(name: string, recursive: bool = false): Instance
486FindFirstChildOfClass(className: string): Instance
486FindFirstChildWhichIsA(className: string, recursive: bool = false): Instance
486FindFirstDescendant(name: string): Instance
563GetActor(): Actor
486GetAttribute(attribute: string): Variant
462GetAttributeChangedSignal(attribute: string): RBXScriptSignal
631GetAttributes(): Dictionary
648GetChildren(): Instances
462GetDebugId(scopeLength: int = 4): string
486GetDescendants(): Array
486GetFullName(): string
641GetStyled(name: string): Variant
657GetStyledPropertyChangedSignal(property: string): RBXScriptSignal
576GetTags(): Array
576HasTag(tag: string): bool
486IsAncestorOf(descendant: Instance): bool
486IsDescendantOf(ancestor: Instance): bool
664IsPropertyModified(property: string): bool
698QueryDescendants(selector: string): Instances
573Remove(): null
576RemoveTag(tag: string): null
664ResetPropertyToDefault(property: string): null
573SetAttribute(attribute: string, value: Variant): null
462WaitForChild(childName: string, timeOut: double): Instance
648children(): Instances
553clone(): Instance
573destroy(): null
553findFirstChild(name: string, recursive: bool = false): Instance
648getChildren(): Instances
553isDescendantOf(ancestor: Instance): bool
573remove(): null
462AncestryChanged(child: Instance, parent: Instance)
462AttributeChanged(attribute: string)
462ChildAdded(child: Instance)
462ChildRemoved(child: Instance)
462DescendantAdded(descendant: Instance)
462DescendantRemoving(descendant: Instance)
500Destroying()
657StyledPropertiesChanged()
553childAdded(child: Instance)
inherited from Object
647ClassName: string
647className: string
647GetPropertyChangedSignal(property: string): RBXScriptSignal
647IsA(className: string): bool
650isA(className: string): bool
647Changed(property: string)

Description

TextService is internally responsible for handling the display of text.

History 19

Members 8

FilterAndTranslateStringAsync

Parameters (4)Default
stringToFilterstring
fromUserIdint64
targetLocalesArray
textContextTextFilterContextPrivateChat
Returns (1)
TextFilterTranslatedResult

This method is no longer supported and should not be used. Translating chat messages is only available via TextChatService.

This function yields. It will block the calling thread until completion.

History 2

Tags: [Yields]

FilterStringAsync

Parameters (3)Default
stringToFilterstring
fromUserIdint64
textContextTextFilterContextPrivateChat
Returns (1)
TextFilterResult

This method filters a string being received from a user and returns a TextFilterResult which can be used to distribute the correctly filtered text accordingly.

This method should be called once each time a user submits a message. If it fails, do not display the text to any user.

See text filtering for usage guidelines and examples.

Notes

  • This method always yields to make a text filtering service call.
  • This method may throw if there is a service error that cannot be resolved. In such cases, do not retry the request, as this method implements its own retry logic internally.
  • This method currently throws if fromUserId is not online on the current server.
This function yields. It will block the calling thread until completion.

History 5

Tags: [Yields]

GetFamilyInfoAsync

Parameters (1)
assetIdContentId
Returns (1)
Dictionary

Returns a table containing the name and faces of a font family. If the font family has already been loaded by a previous call to GetFamilyInfoAsync(), ContentProvider:PreloadAsync(), or a text object with the TextLabel.FontFace property set, then the method returns without yielding.

This method can fail because of network errors and should be wrapped in pcall() to catch and handle errors.

This function yields. It will block the calling thread until completion.

History 2

Tags: [Yields]

GetFontMemoryData

Parameters (0)
No parameters.
Returns (1)
Dictionary

History 1

GetTextBoundsAsync

Parameters (1)
paramsGetTextBoundsParams
Returns (1)
Vector2

Computes the Vector2 dimensions (in pixels) that will be taken up with text when using parameters defined in a GetTextBoundsParams object. This method is similar to GetTextSize() but uses the Font object which has access to more fonts than Font.

This method is a useful alternative to the TextBounds property of the TextLabel/TextButton objects, since GetTextBoundsAsync() can calculate the dimensions required by a particular text string in a TextLabel or TextButton before such an object is created or text property set.

This is a yielding method because some fonts may need to be loaded in order to measure them. As a result, it should be wrapped in pcall() to catch and handle errors. If the font is already loaded, it will not yield; ContentProvider:PreloadAsync() can be used to make sure a font is loaded.

This function yields. It will block the calling thread until completion.

History 1

Tags: [Yields]

GetTextSize

Parameters (4)
stringstring
fontSizeint
fontFont
frameSizeVector2
Returns (1)
Vector2

Computes the Vector2 dimensions (in pixels) that will be taken up with text when using the specified formatting parameters and size constraints.

This method is a useful alternative to the TextBounds property of the TextLabel/TextButton objects, since GetTextSize() can calculate the dimensions required by a particular text string in a TextLabel or TextButton before such an object is created or text property set.

This method is limited to fonts under Font. To access more fonts under Font, use GetTextBoundsAsync() instead.

History 3

GetTextSizeOffsetAsync

Parameters (2)
fontSizeint
fontFont
Returns (1)
float

Returns the offset used to up-scale text based on GuiService.PreferredTextSize, a property which may change through the player's setting in the Roblox or in‑experience Settings menus.

This offset can be used as an additive value to adjust the core height value of a TextLabel or TextButton based on PreferredTextSize.

Note that, currently, the fontSize and font parameters do not affect the outcome and this method returns merely the offset as described above. Also note that this method can fail because of network errors and should be wrapped in pcall() to catch and handle errors.

This function yields. It will block the calling thread until completion.

History 1

Tags: [Yields]

SetResolutionScale

Parameters (1)
scalefloat
Returns (1)
null

History 3

Settings