Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How can I correctly size a text label?

I tried to make a text label the exact right size (using code) to fit the text perfectly, but it didn't work :(

Heres what I tired to use but I couldn't understand it so I made my own not working one Not a IP logger

Here are some of the text settings: Font Size - 18 Font - GothamBold X Snapping - left

Useful info, it needs to return a Udim2 if offset form NOT SCALE!!!!!

1 comment

0

If you want the text to fit you just can enable TextScaled property

2 answers

If you really don't want to use Scale, then you can do some brain breaking math to center it regardless of resolution. You need to take advantage of the AnchorPoint property. Normally setting AnchorPoint to (0.5,0.5) and Position to (0.5,0.5) would do it, but depending on what you are trying to do you have to try with different values.

6 comments

0

I am trying to scale the box to fit the text perfectly

0

I explained exactly what to do in my answer

0

You are positioning it to the center of the screen

0

Yeah, but it was just an example bruh

0

Im trying to SCALE to the correct size to perfectly fit the text

0

Exactly, I gave you an example so you can adjust it for your need

All you have to do is shrink the text box until the TextFits property is false, then set it to one increment larger so it's as small as it can be with the text still fitting in the text box.

1 comment

0

How do I do that via script?

This discussion is preserved as it was. New answers, comments, and votes are closed.