Skip to main content

HudTextbox

Provides properties and functions to interact with a textbox in the HUD.

Properties

id

Gets the unique identifier (ID) for the button. This property is read-only.

position

Gets or sets the position (Vector2).

anchor

Gets or sets the position anchor (Vector2).

pivot

Gets or sets the pivot (Vector2).

fontSize

Gets or sets the size of the font.

foregroundColor

Gets or sets the Color of the foreground.

backgroundColor

Gets or sets the Color of the background.

borderColor

Gets or sets the Color of the border.

textColor

Gets or sets the Color of the text.

borderRounded

Gets or sets a boolean that controls whether the border is rounded.

text

Gets or sets the text content.

Functions

setText(textbox, text, target)

Sets the text content.

Example

local textbox = HudTextbox.new({
text = '',
position = Vector2.new(0, -100),
anchor = Anchor.top,
pivot = Pivot.top,
backgroundColor = Color.new(255,0,0),
textColor = Color.white,
})

function onPlayerJoin(player)
-- Show a welcome message to this player for 5 seconds
HudTextbox.setText(textbox, 'Welcome!', player)
Task.wait(5)
HudTextbox.setVisibility(textbox, false, player)
end

setVisibility(textbox, visible, target)

Sets the visibility.

Example

local textbox = HudTextbox.new({
text = 'Welcome!',
position = Vector2.new(0, -100),
anchor = Anchor.top,
pivot = Pivot.top,
backgroundColor = Color.new(255,0,0),
textColor = Color.white,
})

function onPlayerJoin(player)
-- Wait 5 seconds, then hide the text from this player
Task.wait(5)
HudTextbox.setVisibility(textbox, false, player)
end

function onStart()
-- Show the text for all players, by default
HudTextbox.setVisibility(textbox, true, Players.All)
end