So this code types out any message in a function named ‘DisplayMessage’. It creates a textlabel for every piece of the message, positions it upwards then tweens it down for a smooth looking effect.
The reason I want this code reviewed, is because I think I’m doing something inefficiently. I’d like to know if there’s an alternative to the ‘positioning’ of each textlabel for X. If you click test in the game you’ll notice sometimes the texts space over or a bit into eachother.
Yeah, I was wondering if there’s an alternative method to making it less wonky. All I’m doing is adding to a variable each time a letter is typed down.
I’m not too familiar with ‘GetTextSize’, but I tried doing what it said on the wiki while kind of referencing off of the code you sent. Long story short, it’s a lot more wonkier than it used to be.
local textService = game:GetService("TextService")
local x = 0
local y = 0
function typeLetter(Letter)
local TL = script:WaitForChild("Letter"):Clone()
TL.Text = Letter
TL.Parent = script.Parent:WaitForChild("DescFrame")
local textSize,font = TL.TextSize, TL.Font
local neededSize = textService:GetTextSize(Letter, textSize, font, TL.AbsoluteSize)
x = x + neededSize.X
print(neededSize.X, Letter)
TL.Position = UDim2.new(0, x, y - 0.1, 0)
TL:TweenPosition(UDim2.new(0,x,y,0),"Out", "Quad", .1, true)
if x > 200 then
y = y + .4
x = 0
end
if Letter == "." or Letter == "!" or Letter == "?" then
wait(.5)
end
end