Changing Text Styling Using Code

Changing Text Styling Using Code

Mar 30 2021, 5:19 AM PST


You want to change the style of the text of a TextLabel.


Use several style properties of the TextLabel.

local screen, text = Instance.new('ScreenGui'), Instance.new('TextLabel')
screen.Parent = game.StarterGui
text.Parent = screen
text.Text = 'Hello world'
text.Position = UDim2.new(.375, 0, .375, 0)
text.Size = UDim2.new(.25, 0, .25, 0)
text.Font = 'Arial'
text.FontSize = 'Size36'


The first thing we did was center the text. We took ½ and subtracted it by ½ of the width and height so ½ - ¼ * ½ = ⅜ or .375. So we set the position to be a UDim2 with both scale components to be ⅜ and the Size to be ¼. Now, what does Size do in a TextLabel? Isn’t a TextLabel just text? Size will create a rectangle around your text. There are many properties that control the attributes of this rectangle, but those will be discussed later on.

The next thing we did we set the font to be “Arial”. There are 3 options in which you can set Font to be, Arial, Legacy, and ArialBold. We then set FontSize to be “Size36”. These are the sizes available to you, Size8, Size9, Size10, Size11, Size12, Size14, Size18, Size24, Size36, and Size48.

  • text
  • font
  • gui
  • coding
  • script