Typewriter help

Hello fellow devforum members
me hello

local TextService = game:GetService("TextService")
local TweenService = game:GetService("TweenService")

local UI = script.Parent
local Frame = UI.TextFrame
local TextDefault = script:WaitForChild("Letter")

local X, Y = 0, 0
local TotalX = 0

local LastLetter : TextLabel = nil

local function TypeLetter(Letter : string)
	if TotalX >= Frame.AbsoluteSize.X then Y += 1 TotalX = 0 X = 0 LastLetter = nil end
	
	local Clone = TextDefault:Clone()
	Clone.Text = Letter
	local Position
	if LastLetter ~= nil then
		Position = UDim2.new(0, LastLetter.Position.X.Offset + TextService:GetTextSize(LastLetter.Text, LastLetter.TextSize, LastLetter.Font, LastLetter.AbsoluteSize).X + TextService:GetTextSize(Letter, Clone.TextSize, Clone.Font, Clone.AbsoluteSize).X, Y * Clone.Size.Y.Scale)
	else
		Position = UDim2.new(0, 0, Y * Clone.Size.Y.Scale)
	end
	
	TweenService:Create(Clone, TweenInfo.new(.3, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut), {
		Position = Position,
	})
	
	Clone.Position = Position
	Clone.Parent = Frame
	
	X += 1
	TotalX = Position.X.Offset
	
	LastLetter = Clone
end

game.ReplicatedStorage.Event.Event:Connect(function(Sentence : string)
	for i = 1, #Sentence do
		TypeLetter(string.sub(Sentence, i, i))
		task.wait(.05)
	end
end)

but it instead results in this
image
okay help me now thanks

1 Like

Half fixed it by adding

TextService:GetTextSize(LastLetter.Text, LastLetter.TextSize, LastLetter.Font, LastLetter.AbsoluteSize).X

to the new letter offset,
image
Breaks on characters like “m” tho
image
someone help me out please

Are you trying to do this in one text lable or multiple. If multiple i would recomend you not use that method. Espesialy since you can achive the same effec in side text labels useing the MaxVisibleGraphemes property

I am trying to make it multiple and i need multiple because im making a text falling down effect.

Heres the current version im trying to fix right now with the text falling

Hi there, not sure if you already fixed the text spacing issue, but here’s what I found.

Change the automatic size of the label to X and change the X size to 0.
You can keep the Y size at whatever you had it.
Bild_2024-04-17_212954866

In your code, just change the following:

-- Change this...
LastLetter.Position.X.Offset + TextService:GetTextSize(LastLetter.Text, LastLetter.TextSize, LastLetter.Font, LastLetter.AbsoluteSize).X + TextService:GetTextSize(Letter, Clone.TextSize, Clone.Font, Clone.AbsoluteSize).X

-- ...to this
LastLetter.Position.X.Offset + TextService:GetTextSize(LastLetter.Text, LastLetter.TextSize, LastLetter.Font, LastLetter.AbsoluteSize).X

Just make sure you check if the letter is a space if you don’t already, and just give it a fixed X size.

Didn’t help at all

yo can someone help bro? this is urgent

Can someone help bruh I really need this :skull:

Is this one text instance?
Can you take a picture of the UI in the explorer?
Can you take a picture of the text’s property?

Ill make a new post with more detail in a second

Advanced typewriter - Help and Feedback / Scripting Support - Developer Forum | Roblox I made a new post with more detailed