-
I want to make a sound play each time a letter is added, but my attempts at it won’t work.
-
But the issue is that my For loops won’t work, and I find it kinda hard to get the code from other topics in the DevForum into the AnimateUI code. I also tried to do GetPropertyChangedSignal(“Text”), but that also didn’t work. The sound I’m using is 0.134 seconds long, and I’m not sure if that’s the problem.
This is the part of code I use. It’s the AnimateUI module that Roblox made and put on the DevHub, and I changed it a little. I’m new to strings and all that, so I don’t have any idea on how to go about this.
Sorry if any of this is confusing, if you need me to explain something you didn’t understand feel free to reply
if guiObject.Parent.Visible == false then -- Checks if the Dialogue frame isn't visible; It turns invisible after Dialogue is finished
guiObject.Parent.Visible = true
guiObject.Visible = true
guiObject.AutoLocalize = false
local displayText = text
-- Translate text if possible
if translator then
displayText = translator:Translate(guiObject, text)
end
-- Replace line break tags so grapheme loop will not miss those characters
displayText = displayText:gsub("<br%s*/>", "\n")
displayText:gsub("<[^<>]->", "")
if string.gmatch(text, ".") then
wait(1)
end
for i = 1,#text do -- Sound play part
guiObject.Parent.Parent.Text:Play()
guiObject.Parent.Parent.Text.Ended:Wait()
end
-- Set translated/modified text on parent
guiObject.Text = displayText
guiObject.Parent:FindFirstChild("ImageLabel").Image = "http://www.roblox.com/asset/?id="..ID
local index = 0
for first, last in utf8.graphemes(displayText) do
index = index + 1
guiObject.MaxVisibleGraphemes = index
wait(delayBetweenChars)
end
wait(2)
guiObject.Text = "..."
guiObject.Parent.Visible = false
end
end