How do I detect text outside of a TextLabel?

I am trying to get text outside of a TextLabel so that I can make a multi line chat-like gui without using TextLabel.TextWrapped. However, I am not sure how to do this.

image
I want to be able to get the part in the red box.

3 Likes

I’d recommend that you use the TextLabel.TextFits property.

For my Radio, I calculate the bounds using TextService:GetTextSize and calculate each component size, as well as spacing etc, in a custom function - it is a very fiddly system to actually implement though.

Here is what my implementation looks like.

2 Likes

I’m trying to do something similar, except I want to be able to make the message a separate TextLabel entirely so that I am able to do this:

image

Which also allows me to control the spacing in between each line.

2 Likes

Ah!

Yes, this will be slightly more complex. I’d recommend calculating the text size required to max out a line (with TextService), and then cutting off at each of those points.

1 Like

Looks like you may still need a separate TextLabel, however since you mention it:

TextLabel.LineHeight

4 Likes

I noticed that the default chat GUI managed to be able to do this and after digging in to it, I found out how.

image

image

The message text is all inside of one TextLabel which has the size UDim2.new(1, 0, 1, 0) and leaves spaces in the text at the beginning for the players username to fit. The size of the holder frame and the amount of spaces needed can be calculated with TextService:GetTextSize.

8 Likes