TypeWriter String Breaks lines

Hello i need help fixing this issue, i dont know how to explain it but ill try my best.
I want to fix the issue where the sentence isnt fully finished (Every letter is a different textlabel)

local Fired = false
local Spaces = 0
local function TypeLetter(sentence,color)
	for i, last in utf8.graphemes(sentence) do
		if Fired == true then
			local character = string.sub(sentence, i, last)
			Letter = string.sub(sentence, i, i)
			if TotalX >= Frame.AbsoluteSize.X then
				Y += 0.35 
				TotalX = 0 
				Spaces =0  
				X = 0  
				LastLetter = nil
			end
			local Clone = TextDefault:Clone()

			Clone.Text = Letter
			Clone.Parent = Frame

			local TweenService = game:GetService("TweenService")
			local letterSize = TextService:GetTextSize(Letter, 40, Clone.Font, Clone.AbsoluteSize)
			Clone.Size = UDim2.new(0, letterSize.X, Clone.Size.Y.Scale, 0)

			local Position
			if LastLetter ~= nil then
				local lastLetterPos = LastLetter.Position.X.Offset + (LastLetter.Size.X.Offset / 2)
				Position = UDim2.new(0, lastLetterPos + (letterSize.X / 2) + 0.5, Y * Clone.Size.Y.Scale)
			else
				Position = UDim2.new(0, letterSize.X / 2+ 0.5 , Y * Clone.Size.Y.Scale)
			end

			Clone.Position = Position - UDim2.fromScale(0, 0.05)
			Clone.Name = string.sub(sentence, i, i)

			TweenService:Create(Clone, TweenInfo.new(.15, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut), {
				Position = Position,

			}):Play()




			X += 1
			TotalX = Position.X.Offset + (Clone.Size.X.Offset / 2)

			LastLetter = Clone
			task.wait(.025)
		else
			break
		end
		
	end
	
	Fired = false
	TotalX = 0  X = 0  LastLetter = nil
	Y = 0
	Spaces = 0
end

Did you try their example type writer code? Is this the way you wanted?

1 Like

Sorry for the late reply but yes but also no, i do want a typewriter but with animations (as you can see in the video the fall down in place and color tween of each letter) is what i feel like is suited for my game. I appreciate your reply and i thank you alot but ive found my solution already.

1 Like