I've been working on a typewriter effect which also deals with XML tags, the XML tag typewrtier effect overwrites the normal one to type out the tagged text. For some reason when I try to set i to y+1 (end of the XML tags so it does not just type them out again but normally) it does not work and instead just resumes from the point the normal typewriter was stalled at? Help?
local Texter = script.Parent
local Transp = script.Parent.Parent.Transparent
local Text
local FollowUp = 1
--[]{FINDER VARIABLES}[]-------------------
local DotFinder
local CommaFinder
local QuestionFinder
local ExclaimFinder
local ON = false
local m
local n
local s
local x
local y
local s2
local f
local before
local L
-------------------
function setText(word)
Text = word
for i = 1, #Text do
if ON == false then
string.sub(Text, 1, FollowUp)
Transp.Text = string.sub(Text, 1, i)
wait()
Texter.Text = string.sub(Text, 1, i)
end
if y ~= nil then --///[[This also does not work?? wtf--]]\\\
i = y+1
y = nil
end
m = string.find(Texter.Text, "<", i)
if m ~= nil then
ON = true
n = string.find(word, ">", string.len(Texter.Text))
s = string.sub(Text,m,n)
x = string.find(word, "<", n+1)
y = string.find(word, ">", x+1)
s2 = string.sub(word,x,y)
f = string.sub(word,n+1,x-1)
before = string.sub(Texter.Text,0,string.len(Texter.Text)-1)
for c = 1, #f do
Transp.Text = before..s..string.sub(f, 1, c)..s2
wait()
Texter.Text = before..s..string.sub(f, 1, c)..s2
end
i = y+1 --///[[The i variable of the loop would never cahnge to y+1 and continue the typrewriter effect from the right spot for some reason???--]]\\
m = nil
ON = false
end
end
end
setText('Hey, can you find<font color="rgb(255,165,0)"> orange</font>?')
I've left out some parts, as they are not related. This is why there may be random variables which dont seem to do anything

7 comments
Even more weirdly, after doing some testing it seems i IS setting to y+1 but for some reason reverts to 18 (start of tagged area)???
The variable "i" is auto-set to conform with the condition presented in the generic loop. You do not have control over this variable. The statement "y ~= nil" responds with false as the variable was never assigned a value.
i think i is already taken by the loop, so its a local variable (i think)
It's early in the morning for me, if there is a better approach to this, please take it over my current solution. I would personally design a function to extract and organize all of the XML attributes within the text into an array consisting of the text itself and it's designated colour. Then, iterate through said array and append each letter from this text piece individually—
—while applying its respective properties. If you haven't figured out how to do so by the time I awake, I'll return here to help you out!
I can tell you that you're taking an unnecessarily complex approach to this though, which may result in a harder time trying to implement features. I'd suggest you start over to have an easier time.
@Ziffxture leave an answer so I can upvote you, your comment helped me get my final answer to the problem