Custom Chat Sizing and Text Lines

I am trying to create a custom chat, but have run into multiple issues. How do I account for sizing the message frame “Template” and the size of the text inside of the ScrollingFrame?


I cannot use scale because when the CanvasSize property changes the frame will stretch to match the percentage of the size as expected. And if I use offset I would have to use an AspectRatioConstraint but that prevents me from resizing. I know I could calculate the aspect ratio again, but wouldn’t that mean I would have to loop through the already exisiting messages? I am really confused on how to go about doing this.

I have tried looking this up but nothing seems to fit my exact needs.

The other issue is when the size of the window or gui changes, would I have to loop through all the messages and have some equation that calculates their new size? This has got me stuck for hours so I decided to give it a shot here.

Thanks in advance.

NOTE: I am going to attempt to use RichText, meaning TextScaled will not work for sizing the font.


Use scale of X, use offset for Y, where the Y of the template size is the length of the Message returned by TextService:GetTextSize, use UIListLayout and get the AbsoluteContentSize, and then set CanvasSize to 1,0,0,Y where Y is AbsoluteContentSize.Y

I do indeed use scale for X and offset for Y for the template size and I also do the AbsoluteContentSize thing. I have a ListLayout as well. Would your answer solve my issue of first of all providing the ability for the text to span multiple lines as well as appropriate sizing when the window size changes?

Also something important to note is that I am using RichText so TextScaled is not an option. I am confused on how I would go about resizing the text to account for window size changes. I could loop through all of the messages and change the TextConstraint properties, but that seems highly inefficient. Do you have a better method to suggest in regards to this?

1 Like

Use TextService:GetTextSize, you don’t need TextScaled for this, just TextWrapped.

and then use the Vector2 returned by that function, to set the size of the message, as well as the parent. Then, set the CanvasSize.Y.Offset to UIListLayout.AbsoluteContentSize.Y

1 Like

This works, however, if, for example, I resize the window down to let’s say a phone, the text is very enlarged and does not scale appropriately.

Simple, decrease the font size if the screen size is below a certain point

Yes, but that would require me to loop through the already existing messages in the scrolling frame, which seems highly inefficient. Is there a better method or am I simply misunderstanding you?

You don’t have to, the phone screen size is much smaller than the minimum window size for Mac and windows. You can simply add an if statement to check the screen resolution and determine whether use the smaller one or larger one.

Yeah, so I figured out RichText does not have support for TextScaled and GetTextSize yet, so I guess I will have to wait for those features to come out in order to do what I want. For now, I will just stick to using TextScaled and GetTextSize without RichText. Thanks for the help anyways.