I’m terrible when it comes to figuring out string patterns. Today I decided I would try to make a gui similar to the dev console. Easy enough. The only problem is highlighting the text just like the script editor. The method I came up with was to use rich text and use string.gsub
to replace the keywords.
I keep getting this error:
ScriptGui.TextHighlighter:63: invalid capture index %1
I genuinley have no clue what it means. Could someone point me in the right direction when it comes to this stuff?
The error happens on this line btw:
if string.match(TextBox.Text, "%"..Keyword) then
Full Script:
local Terms = {
["StringCharacters"] = {"'",'"'},
["MathStuff"] = {"1","2","3","4","5","6","7","8","9","0","+","-","*","^",".","%","[","]","{","}",":",";","=","!","~","(",")",","},
["Globals"] = {"and", "break", "do", "else", "elseif", "end", "false", "for", "function", "if", "in", "local", "nil", "not", "or", "repeat", "return", "then", "true", "until", "while"}
}
local function HighlightTextbox(TextBox)
for KeywordType, KeywordTable in pairs(Terms) do
for _,Keyword in pairs(KeywordTable) do
if string.match(TextBox.Text, "%"..Keyword) then
-- The error happens here :(
end
end
end