Hey! I’m making an ‘advanced’ dialogue system. This means that if the text includes a . , ! or ? it will wait a custom amount of seconds before continuing the sentences. I want to switch the if statements to this dictionary:
local Dictionary = {
["."] = 1;
["!"] = 1;
["?"] = 1;
[","] = 0.5;
}
The current textloop looks like this: (working)
local Comma = ","
local Period = "."
local Exclamation = "!"
local QuestionMark = "?"
for i = 1, #Text do
Frame.Dialogue.Text = string.sub(Text, 1, i)
local Time = 0.1
if string.sub(Text, i, i) == Comma then
Time = 0.5
elseif string.sub(Text, i, i) == Period or
string.sub(Text, i, i) == Exclamation or
string.sub(Text, i, i) == QuestionMark
then
Time = 1
end
task.wait(Time)
end
I’ve tried to make it a dictionary supported by doing thing such as:
for i = 1, #Text do
local sub = string.sub(Text, 1, i)
Frame.Dialogue.Text = sub
local Time = 0.05
for x, v in pairs(string.split(Text, "")) do
if Dictionary[v] then
Time = Dictionary[v]
warn(Time)
end
end
task.wait(Time)
end
The issue with this code is that because I do string.split it splits the entire sentence and ofcourse it’ll register multiple periods, commas, etc. such as in the code below.
Type("You are going to die, muhahhaa! Are you ready to die, friend? I will kill you!", "The Jester", Color3.fromRGB(255, 0, 0))
I’ve had no success so far. Does anyone know a solution? Thank you!