How to make a textlabel the size of the text

is there a way to make it so the size of the actual background gui scales with the amount of text?

You can either enable AutomaticSize for the label, or you can use TextService:GetTextBoundsAsync() as AutomaticSize can be a bit finicky.

1 Like

Yes, you can use the TextBounds property of a TextLabel to determine the size of the text and then adjust the size of the background Frame accordingly:

local gui = script.Parent
local textLabel = gui.TextLabel
local backgroundFrame = gui.Background

    local textBoundsSize = textLabel.TextBounds.Size
    backgroundFrame.Size =, textBoundsSize.X + 10, 0, textBoundsSize.Y + 10)

This script listens for changes to the TextBounds property of the TextLabel , which is triggered whenever the text size changes. When the text size changes, the script updates the size of the background Frame to fit the text.

In this example, the Background frame has a padding of 10 pixels added to the TextBounds size to give some extra space around the text. You can adjust this value to suit your needs.

Enable TextScaled on the textlabel.

1 Like

I was about to write it here lol.