Basically, I made a module that separates each character of a string into it’s own TextLabel so I’m able to animate it later. The issue is that I don’t know how to fix the spacing between letters, because there’s too much on some (as you can see with “l” or “i”) and too little on others (like with “m” and “a”).
You can use TextLabel.MaxVisibleGraphemes to animate it.
Example:
local label = PATHTOLABELHERE
local speed = .5
local increment = .5
local function animateLabel(speed : number, increment : number)
if label.MaxVisibleGraphemes == 0 then
task.spawn(function()
while wait(speed) do
label.MaxVisibleGraphemes = label.MaxVisibleGraphemes+increment
if label.MaxVisibleGraphemes == label.Text:len() then
break
end
end
end)
elseif label.MaxVisibleGraphemes == label.Text:len() then
task.spawn(function()
while wait(speed) do
label.MaxVisibleGraphemes = label.MaxVisibleGraphemes-increment
if label.MaxVisibleGraphemes == 0 then
break
end
end
end)
end
end
animateLabel(speed, increment)
I don’t think you understood my issue, if you look at the video, you can see that for example in “make” or “doing” there are some weird spaces between the letters, that’s what I’m trying to get rid of.
It’s probably from each separate TextLabel being spaced out too far. If you use one TextLabel you are able to control the spacing easier. Apologies for my lack of explanation.
That’s exactly what I’m using for this, I THOUGHT I could maybe use it individually for each character but it always return the same size, no matter the letter.
Here’s the code if it helps:
function TextModule.Write(Frame, Text)
local TextSize = game:GetService("TextService"):GetTextSize(Text, TextFontSize, TextFont, Vector2.new(math.huge, math.huge))
local char_size = TextSize.X/#Text
local Separated_Text = separate_Text(Frame, Text, TextSize) --This returns an array of the text divided in several lines
for _i, v in pairs(Separated_Text) do
for i, v in pairs(Frame:GetChildren()) do
if v.Name ~= "".._i then
v.Position = v.Position + UDim2.new(0, 0, -.06, 0) --This moves all previous lines upwards
end
end
for i=1,#v,1 do
local Label = script.Example:Clone()
Label.Parent = Frame
Label.Name = _i
Label.Size = UDim2.new(0, char_size, 0, TextSize.Y, 0)
Label.Position = UDim2.new(0, (Frame.AbsoluteSize.X / 2) + (i * char_size/2), .5 + ((.06 * (_i-1))), 0)
Label.Text = v:sub(i,i)
Move_Chars(_i, Frame, char_size) --Moves all characters in the same line to the left
task.wait(.05)
end
end
end
Threw this script together;
pretty much proves ur point
local st = "The quick brown fox jumps over the lazy dog."
local ts = game:GetService("TextService")
local font = Enum.Font.RobotoMono
for i = 1, #st do
local char = st:sub(i, i)
local width = ts:GetTextSize(char, 40, font, Vector2.new(math.huge, math.huge))
print(char .. " ; " .. width.X)
end