Code wont work as intended

I am creating a text engine and its done and all but there is 1 error that ruins the beauty of it.
image
see it yet? It makes a new line after half of it is full while it should make it full.

this is the part of the code that doesnt work as intended

local function MakeLine(Parent:TextLabel)
	Index = 1
	local Frame = Instance.new("Frame")
	Frame.Parent = Parent
	Frame.Size = UDim2.new(1,0,0,Parent.TextSize)
	Frame.Transparency = 1
	Lines += 1
	local UIListLayout = Instance.new("UIListLayout")
	UIListLayout.Parent = Frame
	UIListLayout.FillDirection = Enum.FillDirection.Horizontal
	UIListLayout.SortOrder = Enum.SortOrder.LayoutOrder
	Frame.Name = "Line "..Lines
	return Frame
end
-- Start
	for i,word in pairs(strtable) do
		local color = wordcolors[i]
		local hl = highlight[i]
		local space = i==strtable and "" or " "
		local img = nil

		for name,id in pairs(Emojis) do
			if name == word then
				img = id
				break
			end
		end
		
		if img then
			if MakeImage(img,Label,frame,true,Label) then
				MakeImage(img,Label,frame,false)
			else
				frame = MakeLine(Label)
				MakeImage(img,Label,frame,false)
			end
		else
			if MakeLabel(word..space,Label,frame,true,color,hl,Label) then
				MakeLabel(word..space,Label,frame,false,color,hl)
			else
				frame = MakeLine(Label)
				MakeLabel(word..space,Label,frame,false,color,hl)
			end
		end
		wait()
	end

I didnt give the full code because the other part isnt much its just functions and other stuff e.t.c

This is the message in explorer


and
this is the base message
image

1 Like

Is the value of Lines the same as the current number of lines being displayed?

ofc it is its not the problem with lines numbering.