I have a few lines of code that are supposed to change the text label's Y offset if the text doesn't fit, and the only way I can get the text to loop to a new line is with TextWrapped, which also wraps the top and bottom. Here is a sample:
if cht.TextFits == false then cht.TextWrapped = true repeat cht.Size = cht.Size + UDim2.new(0,0,0,15) until cht.TextFits == true end
Sadly I don't have any other examples, and with that example code, the size stays at it's original size of 1,0,0,15 instead of adding length to Y because the TextWrapped also wraps the bottom and top of the label.
Until ROBLOX has enough sense to add a text wrapping that only wraps the sides, I need to figure out how to use TextBounds.
Is there any way to set a limit on the TextBounds.X and then have Y expand accordingly? Or else, how am I supposed to do this?
Thanks in advance for any replies I might get, I've been working on a large chat-based project for the past week and have had this error be produced with no fix for the past 2 days of my used 7, and I only have another week before my "deadline".
Roblox's TextWrapping does not wrap from bottom to top. What you might be observing is the Y-alignment is Center rather than Top, causing the text to start and end off the TextLabel's bounds. You should see your algorithm start to work correctly when you reduce your TextLabel's horizontal size. When you specify UDim2.new(1, 0, 0, 15), you're telling it to take up the entire horizontal space of the parent, meaning that the text already fits, meaning your algorithm won't increase the height of the label.
If you want a specific X-size, you can use TextService:GetTextSize(text, textSize, font, Vector2.new(pixels, 32767))
(you can replace the 32767 with a smaller number, but I believe it's the largest that Roblox will work with). This function will return what TextBounds will become if the TextLabel with that text/textSize/font is pixels
wide.