Hi developers! So I’ve created a dialogue system using the ‘MaxVisibleGraphemes’ feature, in which every grapheme plays a sound. The thing is, my dialogue has RichText, which is why I decided to use this method instead of ‘string.sub’, and it plays a sound for every character inside the RichText, if that makes sense, instead of playing a sound for every grapheme shown. This is what I’m referring to:
The sound keeps playing after the sentence has finished, as if instead of ‘pineapple pizza’, it was playing as '<font color='#ffc637'>pinapple pizza</font>'
or smth. Here is the code I made for the typewriter effect:
local function setText(text, object)
text = text:gsub("<br%s*/>", "\n")
text:gsub("<[^<>]->", "")
local symbols = {",", "%.", "!", "?", ":", ";"}
local detectedSymbol = nil
for i = 1, #text do
object.Text = text
object.MaxVisibleGraphemes = i
for _, symbol in pairs(symbols) do
if string.sub(text, i, i):match(symbol) then
detectedSymbol = symbol
end
end
game.SoundService.clickSound:Play()
if detectedSymbol == "," then
task.wait(0.2)
elseif detectedSymbol == "%." or detectedSymbol == "!" or detectedSymbol == "?" then
task.wait(0.5)
elseif detectedSymbol == nil then
task.wait(0.01)
end
detectedSymbol = nil
end
end
So I was wondering if there was a possible way to make it play just the number of characters shown. I would really appreciate any help! I’m not very good at scripting so yeah, maybe it’s a dumb mistake or whatever. I’ll be reading you guys, thank you!