My code keeps erroring with 3 errors, I tried to make glitching text, Didnt work out

  1. I want to achieve to get glitching text.

  2. It keeps erroring with those errors : malformed pattern (ends with ‘%’), invalid pattern capture, malformed pattern (missing ‘]’)

  3. I Tried a lot of changing the code, Didn’t find any good solutions on the developer hub.

local mode = "Test"
local textMode
local modet = Instance.new('Hint',workspace)
local characters = {}
for i = 1,255,1 do
	table.insert(characters,string.char(i))
end
spawn(function()
	while game:GetService('RunService').Heartbeat:Wait() do
		textMode = mode
		for i = 1,4 do
			spawn(function()
				textMode = string.gsub(textMode, characters[math.random(1,#characters)], characters[math.random(1,#characters)])
			end)
		end
		modet.Text = textMode
	end
end)
local mode = "Test"
local textMode
local modet = Instance.new('Hint',workspace)
local characters = {}
for i = 97,122,1 do
	table.insert(characters,string.char(i))
end

wait(3)
spawn(function()
	while game:GetService('RunService').Heartbeat:Wait() do
		textMode = mode
		for i = 1,4 do
			spawn(function()
				textMode = string.gsub(textMode, characters[math.random(1,#characters)], characters[math.random(1,#characters)])
			end)
		end
		modet.Text = textMode
	end
end)

I fixed the errors, you can attempt to implement the “glitching” effect now.

Welp, It didn’t error but… It didnt function it doesnt change any text. No errors, warns, etc. Maybe ill try editing a bit of the code.

I have found the problem, It was because i didnt change textMode to mode when string.gsub(), And i forgot to put the text after its done gsubing the string. Thank you for trying to help me atleast!

I didn’t try to fix the glitching effect, I was just fixing your errors.

Yes i realized, But i guess it kinda helped me to get it working.