So I was working on a typewriter script. But instead of giving 1 TextLabel text, and using gsub to add to it, I decided to create a TextLabel for every letter being typed down.
To do this I made a function, and this is what I came up with:
local txts = game:GetService("TextService")
function typeLetter(Letter)
local TL = script:WaitForChild("Letter"):Clone()
TL.Text = Letter
local size = txts:GetTextSize(Letter, TL.TextSize, TL.Font, TL.AbsoluteSize)
print(size.X)
XPos = XPos + size.X
if XPos > 100 then
YPos = YPos + .4
XPos = 0
end
TL.Position = UDim2.new(XPos, 0, YPos - 0.1, 0)
TL.Parent = script.Parent:WaitForChild("DescFrame")
TL:TweenPosition(UDim2.new(XPos,0,YPos,0),"Out", "Quad", .1, true)
if Letter == "." or Letter == "!" or Letter == "?" then
wait(.5)
end
end
It was working for a bit, until I noticed something a little weird going on. The typewriter wasn’t positioning the textlabels the way they should be. Here’s an example of what I mean: Combat Scripting - Roblox Studio (gyazo.com)
I actually like the error, gives it a creepy vibe. I don’t see a clear way to fix this problem, so you might need to gsub if you don’t like the creepy vibe lol
@broshv It’s not about the creepy vibe, it’s just the fact that the positioning is off that bugs me. It’s just a little odd how it overlaps other text.
these might be the part that is affecting the positon of the word because its a fixed position you put in lets take M its a bit of a long letter then put I which is a short letter you will position them next to each other within 2 x-axis so the M would clip onto I
Actually the reason for this is because different characters have different spacing and positioning. It might not make sense but i used to have the same problem. To fix this, you have to use a certain function to determine each characters size. Ill reply with it in a bit