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

How would i be able to find the amount of spaces needed for 2 textlabels?

Hey, so i'm trying to make a chat script but it seems impossible with the way I want it. It's basically like the default ROBLOX chat, the sender has a unique color and then the msg color is a basic white.

What the problem is, i don't know how it would be possible to get the amount of spaces needed for example:

Sender: MSG

It would take 7-8 spaces so i can move the MSG next to the :.

However, i've tried using string.rep to get the amount of characters there are in the sender's username but it won't work because it depends entirely on how the sender's username is formatted.

Example;

Sender 1; heroboy10 Sender 2; HeROBOy10

You can see the differences in length of the above. Both have the same amount of characters, and one will look like this:

herobuy10: test message

and

HeROBtest m**:**essage

So basically I need to know how it would be possible like ROBLOX's chat to get the amount of needed spaces. Thanks. Sorry if this seems a little bit too complicated.

1 answer

✓ Accepted answer

I used to have the same problem. There is a value of textlabels named TextBounds. (Read-only) for example:

label1.Position = UDim2.new(0,0,0,0)
label2.Position = UDim2.new(0, label1.TextBounds.X, 0,0)

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