Seems like it would just be a simple lookahead.
How does your typewriting string system currently work. Is it just iterating over the characters in the string displaying each one after a set delay?
You could do something like:
local testString = "Testing Wait string{3} for funsies"
local exploded = testString:split("")
local curIndex = 1
local startChar = "{"
local endchar = "}"
local curWait = ""
while curIndex < #exploded do
if exploded[curIndex] == startChar then
while exploded[curIndex+1] ~= endchar do
curIndex += 1
curWait = curWait..exploded[curIndex]
end
task.wait(tonumber(curWait))
curWait = ""
curIndex += 1 -- skip endChar
else
print(exploded[curIndex])
task.wait(.1)
end
curIndex += 1
end
Ah, so you probably would need to run over your raw strings with your wait tags in before hand and build up the clean text to put into your label and the table.
local testString = "Testing Wait string{3} for fun{5}sies. Because we can."
local cleanString = string.gsub(testString, "{(%d*)}", "")
local waits = {}
while string.find(testString, "{(%d*)}") do
local waitTag = string.match(testString, "{(%d*)}")
local index = string.find(testString, waitTag) - 2 -- back the index up to account for the "{"
waits[index] = tonumber(waitTag)
testString = string.gsub(testString, `\{{waitTag}\}`, "")
end
for i, c in ipairs(cleanString:split("")) do
print(i, c)
if waits[i] then
task.wait(waits[i])
else
task.wait(.1)
end
end