So I'm making a gui where things like errors, warnings, and other general info print out onto a gui so it's easier for myself to read.
However I ran into an issue, where if something copies over that spans multiple lines, it will overlap with the other lines that were made previously
This is some of the code I have for the gui right now.
local canvasX = 0 game:GetService("LogService").MessageOut:connect(function(output, messageType) local newLine = script.NewLine:clone() newLine.Position = UDim2.new(0, 5, 0, (#script.Parent.Scrolling:getChildren() * 15)) newLine.Text = "> " ..output newLine.Name = tick() newLine.Parent = script.Parent.Scrolling newLine.Size = UDim2.new(0, (#output * 10), 0, 15) canvasX = (canvasX > (#output * 10) and canvasX or (#output * 10)) script.Parent.Scrolling.CanvasSize = UDim2.new(0, (canvasX + 10), 0, ((#script.Parent.Scrolling:getChildren() + 1) * 15)) end)
And this is what it looks like printing single lines, compared to when it prints a message with multiple lines.
Single Line: https://i.imgur.com/BJsLxh1.png
Multiple Lines: https://i.imgur.com/gFOJVcI.png
As you can see, my script will copy singular lines just fine, but when something spans multiple lines it will cause interference.
Is there any way to make the TextLabel adjust to how many lines the text spans?
If your TextLabel's text is wrappable and is not automatically sized you can just use the
TextBounds property, it shows how much space does the current text take. Example:
local textSize = label.TextBounds local defaultSize = label.Size label.Size = UDim2.new(0, defaultSize.X.Offset, 0, math.max(textSize.Y, defaultSize.Y.Offset))