Aller au contenu


WorldText is an in-world text CoreObject.


Property Name Return Type Description Tags
text string The text being displayed by this object. Read-Write


Function Name Return Type Description Tags
GetColor() Color The color of the Text. None
SetColor(Color) None The color of the Text. None
SetFont(string fontId) None Sets the text to use the specified font asset. None


Example using:



In this example, a WorldText object that is placed in the scene changes color gradually from white to black. The script expects to be a child of the WorldText. Notice that if you run this in multiplayer mode, the color changes will not be as smooth as in single-player preview. To fix that place the WorldText + Script hierarchy under a Client Context.

local nameTextObject = script.parent

function Tick(deltaTime)
    local c = nameTextObject:GetColor()

    if c.r < 0.03 then
        -- Start over from white (x3 so it stays on white for a bit longer)
        c = Color.WHITE * 3
        c = Color.Lerp(c, Color.BLACK, deltaTime * 2)


See also: CoreObject.parent | Color.Lerp

Example using:


Change the contents of a WorldText object with the text property. In this example, when a new player joins the game their name is written to the WorldText. It's also demonstrated that <br> can be used to insert line breaks. This script expects to be the child of a WorldText object that is placed in the scene.

local nameTextObject = script.parent

Game.playerJoinedEvent:Connect(function (player)
    nameTextObject.text = .. "<br>has joined the game!<br>GLHF!"

See also: CoreObject.parent | Game.playerJoinedEvent | | Event.Connect

Dernière mise à jour: March 15, 2021