Hi, I’m wondering on how I can auto-sale a text label by the string size that is stored in the text label. I’ve been trying and trying but I couldn’t figure out on how to do so. I want the text label to auto-scale on the Y-Axis, but I can’t figure it out. I used string.len to figure out the length of the string then figure out if it’s greater than my maximum string length but I want the Gui to auto sale to the string length. If anyone can help that’ll be great!
No, I used that right now but I want the Text Label size to increase so the text doesn’t get really small, it get’s really small and it looks horrible. Thanks for the reply!
I’ll give you an example of what happens.
The TextBounds property returns a Vector2 value referring to the size of the text displayed. Setting the TextLabel’s size to a value greater than or equal to the X and Y values will always ensure that the text fits inside the TextLabel.
This is exactly what I was looking for, thanks so much man!
In addition to what JoshRBX said, you can use UITextSizeConstraint (together with the TextScaled property) to set a minimum and maximum TextSize value.
You guys are amazing thanks for the help!
It is important to note that TextBounds can only be used if you have an existing TextLabel.
If you’re creating them in a script, and want to have it already sized before you have it show up, you should use TextService.
You’ll be using the :GetTextSize() function. Read up on it here.
This function is a useful alternative to the
TextLabel.TextBounds
property of theTextLabel
andTextButton
objects. Using theTextLabel.TextBounds
property to calculate the dimensions text requires is often impractical as it requires aTextLabel
object to be created.With GetTextSize, the dimensions required by a particular text string in a particular
TextLabel
orTextButton
can be calculated before any object is created or text property set.
I hope you find this helpful!
This will be going live very soon and would be your best option:
Hi, I used @boatbomber suggestion! It worked really well, I’ll be using the new feature once it comes out since it makes it so much easier!
Thanks so much for the reply!