Help on scaling a text box

I am trying to scale a text label to fit the text indide perfectly. I have tried to use this API reference page, but I requires the text label’s size and returns a vector 3. So that didnt work.

Text properties

  • Font - Gotham bold
  • Size - 18
  • Text X Alignment - Left

Some useful info

  • It needs to return offset, not scale
  • If theres any other info you might need please ask

Thanks in advance for anyone who solves this :smile:!

EDIT: Text scaled doesn’t work if you want a lot of labels to be under each other, because they are all different text sizes.

EDIT:
What I have with text scaled:
image
(Notice that the texts are all different sizes)

What I need:
image
(Notice that the sizes are diffrent but the text sizes are all 24)

1 Like

Have you tried using textlabel.TextScaled?

2 Likes

^ There are also TextSizeConstraints if you want a maximum/minimum size

2 Likes

I have but then if you try to put more text labels under each other, they are all different sizes. I am trying to set the text labels size to perfectly size the text. Sorry if I wasn’t clear enough.

1 Like

Like @7z99 said, you should try messing around with TextSizeConstraints and stick with your preference.

1 Like

Do size 1,0,1,0, and TextScaled to true if you’re worried about the size of the labels’ children.

I don’t completely know how to use text constraints

How would this work? I need a list of text object that are all perfectly sized

What I need:
image

What I have using text scaled:
image

1 Like

Oh, I see. You just want the text sizes all the same? I’m a little confused.

it ok, I should ok made myself more clear. I do want all the text sizes to stay the same.

1 Like

so you want the text to all be font size 18 but you want the label sizes to change to the size of the text?

No, I want the text size to permanently stay the same, and only the size of the text label changes. A good example is the default ROBLOX chat system, when a player chats you can notice that their names text size is constant across all messages, but the size changes.

1 Like

He’s asking for the text sizes along with resizing of devices to be the same size. Honestly the only way I do this is by making the text longer on the y axis so words fit inside, if it reaches the end of the textlabel’s y size it will become smaller otherwise it stays the same

1 Like

Maybe you could use the :GetPropertyChangedSignal() on the ViewportSize property in the workspace.CurrentCamera, or the AbsoluteSize property of your TextLabel??

1 Like

I don’t understand. Please give me a bit of extra info, or dumb it down to my level.

1 Like

Alright, try this:

local myContainer = --[[wherever your frame/ScreenGui containing your buttons is]]

for i,v in pairs(myContainer:GetChildren()) do 
    if v:IsA('TextLabel') then
        v:GetPropertyChangedSignal('AbsoluteSize'):Connect(function()
            v.TextSize = v.AbsoluteSize.Y - 10 -- can be whatever, just an example
        end
    end
end

You need to close the third and

end)

I am trying to keep the text size constant, I just need to change the offset of the X and Y, to make the text label fit the text.

Will this help? The ROBLOX chat system is a VERY good example

I don’t understand this. Sorry, but could you please explain it to me better?