So I have a modified typewriter module, and it’s modified to auto-complete the text once the player presses enter. It works, except when the player does press enter, and more than one string has been run through the module, it auto-completes to what the first string sent through was. How do I make it so the function forgets about any previous strings sent through? Any help is appreciated!
Function:
local enterPressed = false
function TypeWriter.typeWrite(guiObject, text)
guiObject.AutoLocalize = false
guiObject.Text = ""
local displayText = text
if translator then
displayText = translator:Translate(guiObject, text)
end
for first, last in utf8.graphemes(displayText) do
if enterPressed ~= true then
UIS.InputBegan:Connect(function(input)
if guiObject.Text ~= " " then
if input.KeyCode == Enum.KeyCode.Return then
guiObject.Text = text
enterPressed = true
end
end
end)
local grapheme = string.sub(displayText, first, last)
guiObject.Text = guiObject.Text .. grapheme
if defaultConfigurations.extraDelayOnSpace and grapheme == " " then
wait(defaultConfigurations.delayTime)
end
if defaultConfigurations.extraDelayOnComma and grapheme == "," then
wait(defaultConfigurations.commaDelay)
end
if defaultConfigurations.extraDelayOnPeriod and grapheme == "." then
wait(defaultConfigurations.delayTime)
end
if defaultConfigurations.extraDelayOnQuesitonMark and grapheme == "?" then
wait(defaultConfigurations.delayTime)
end
if defaultConfigurations.extraDelayOnExclamationPoint and grapheme == "!" then
wait(defaultConfigurations.delayTime)
end
wait(defaultConfigurations.delayTime)
end
end
enterPressed = false
end
