So I am making a small developer GUI. Almost everything in the GUI works except the output. I am trying to scale the text relative to the number to the number of lines.
Here is the code that I tried to use (which just did not work at all)
local LogService = game:GetService("LogService")
local ScrollingFrame = script.Parent
local Preset = ScrollingFrame.ConsoleMSG
local TotalOutputNumber = 0
function setTextAndCountLines (textLabel, text) --This function does not work at all (never returns the correct number)
local counter = 0
local sizeY = 0
for i = 1, text:len() do
textLabel.Text = text:sub(1, i)
if textLabel.TextBounds.Y > sizeY then
sizeY = textLabel.TextBounds.Y
counter += 1
end
end
return counter
end
LogService.MessageOut:Connect(function(Message, Type)
local clone = Preset:Clone()
clone.Parent = ScrollingFrame
clone.Name = tostring(TotalOutputNumber)
TotalOutputNumber = TotalOutputNumber + 1
if Type == Enum.MessageType.MessageError then
clone.Type.TextColor3 = Color3.fromRGB(180, 0, 0)
clone.Type.Text = "[ERROR] -"
elseif Type == Enum.MessageType.MessageWarning then
clone.Type.TextColor3 = Color3.fromRGB(255, 255, 0)
clone.Type.Text = "[WARN] -"
else
clone.Type.TextColor3 = Color3.fromRGB(165, 165, 165)
clone.Type.Text = "[INFO] -"
end
local numberOfLines = setTextAndCountLines(clone.Text, Message)
clone.Size = clone.Size + UDim2.new(0, 0, 0, 19*numberOfLines) --I think I got the math wrong (19 is the size in pixels of a line of text)
clone.Visible = true
end)
I do not know a way to fix this. The script makes my output window look like this:
This is the setup in the explorer 