I’m working on a dialogue system that uses custom text (for the aesthetic) and I’m not sure on how to stop at certain points where the word goes beyond the frame.
What I want to achieve is that after “afas” it goes into another paragraph which reads “Hello yes”
local sizemod = 0
local paragraph = makeparagraph()
paragraph.Parent = Gui
paragraph.LayoutOrder = index
for character in txt:gmatch(".") do
local element = makeframe(character)
local label = element.TextLabel
label.TextTransparency = 1
label.TextStrokeTransparency = 1
label.Position = UDim2.new(0.5, 0, 0.5, 2)
sizemod += element.Size.X.Offset
if sizemod >= 397 then
paragraph = makeparagraph()
paragraph.Parent = Gui
paragraph.LayoutOrder = index
sizemod = 0
end
-- Animate:
element.Parent = paragraph
index += 1
TweenService:Create(label, TweenInfo.new(0.1), {TextTransparency = 0, TextStrokeTransparency = 0.5, Position = UDim2.fromScale(0.5, 0.5)}):Play()
-- Delay:
local extension = character == "," and 0.35 or (character == "." or character == "?" or character == "!") and 0.75 or 0
task.wait(0.05 + extension)
end