Hello, I am currently scripting a police Radio. I have come to a point, where I want to size the TextLabel automatically from the content. Any ideas? Thanks, Alex
✓ ANSWER ACCEPTED
How do I let a TextLabel size automatically according to the text?
2 answers
✓ Accepted answer
You could use TextService
TextService has a function called :GetTextSize() and it returns a Vector2 which contains an X and Y to scale your TextLabel. Make sure your TextLabel is Scaled.
local TS = game:GetService("TextService")
local message = script.Parent
local frame = script.Parent.Parent
local fontSize = Enum.FontSize.Size18
local font = Enum.Font.SourceSansLight
local newSize = TS:GetTextSize(message.Text,fontSize,font,frame.AbsoluteSize)
message.Size = UDim2.new(0,newSize.X,0,newSize.Y)
OR
You can just use TextBounds
Either or works!
Hope this helped!
In the properties of the textlabel scroll down to the text section(where you would do stuff like change what the text says or change the text color) and select the box that says "TextScaled." And done! Or in a script it would be for example:
local player = game.Players.LocalPlayer
local pguiLabel = player.PlayerGui:WaitForChild("ScreenGui").Frame.TextLabel
pguiLabel.TextScaled = true
Please accept this answer if it helped.
This discussion is preserved as it was. New answers, comments, and votes are closed.

5 comments
Sorry, but that is not what I mean. I mean that the textLabel gets multiple lines. The TextLabel comes from a clone out of RS.
Just like in the Roblox built-in chat.
TextScaled will give the text multiple lines if it is too long.
But in the roblox built-in chat, the text isn't scaled. The "borders" of the textLabel expands, when the text has reached a certain length.
You have got to make your question more specific then.