Hello people, I was writing a code to make letters appear one by one in a dialogue. So that when a symbol (e.g.: comma, dot, semicolon, etc.) comes up, it would stop for a selected amount of time. I made a table for those symbols, but for some reason, when I run it it detects every letter as a dot and pauses longer than the expected amount. I can’t understand why it detects every letter as a dot, but when I remove the dot from symbols table it behaves normally.
Heres the script:
local SymbolsTable = {",", "!", "?", " ", "."}
local function letterAppear(object, text)
local detectedSymbol = nil
for i = 1, string.len(text) do
object.MaxVisibleGraphemes = i
for _, symbol in pairs(SymbolsTable) do
if string.sub(text, i, i):match(symbol) then
print("Detected letter: "..string.sub(text, i, i))
print("Detected symbol/space: "..symbol)
detectedSymbol = symbol
end
end
if detectedSymbol == "," then
task.wait(0.2)
elseif detectedSymbol == "." or detectedSymbol == "!" or detectedSymbol == "?" then
task.wait(0.5)
elseif detectedSymbol == " " then
task.wait()
elseif detectedSymbol == nil then
task.wait(0.02)
end
detectedSymbol = nil
end
end
letterAppear(script.Parent.Dialogue, script.Parent.Dialogue.Text)
When dot is added to the symbols table, the output shows this:
When it’s removed:
Is this a bug in the engine, or have I written something wrong in the code that I missed?