The text to be cut every 29 characters and wrapped to a new line, and at 250 be cut off and stopped with …
My code will not work and there aren’t any errors.
Code
messages.new = function(text : string, color : Color3, font : Font)
local template = script.MessageTemplate:Clone()
if text:len() > 31 then
local formattedText = ""
local maxLength = 250
local lineLength = 29
local textLength = math.min(#text, maxLength)
for i = 1, textLength, lineLength do
if i + lineLength > maxLength then
formattedText = formattedText .. string.sub(text, i, maxLength) .. "..."
break
elseif i + lineLength - 1 >= textLength then
formattedText = formattedText .. string.sub(text, i, textLength)
else
formattedText = formattedText .. string.sub(text, i, i + lineLength - 1) .. "\n"
end
end
text = formattedText
end
template.Text = text
template.TextColor3 = color
template.Font = font
template.Parent = script.Parent.Parent.ChatWindow
template.LayoutOrder = #script.Parent.Parent.ChatWindow:GetChildren()
template.Visible = true
template.Name = text
end