zCrxtix
(zavier)
August 21, 2021, 1:38am
#1
I used the code from this post.
I’m not sure how to explain it, so here’s a video:
Code:
editor:GetPropertyChangedSignal("Text"):Connect(function()
local syntax = editor.Text
shower.Text = syntax
for _, v in pairs({"int", "local", "for", "in", "do"}) do
syntax = syntax:gsub("(%W?)(".. v.. ")(%W?)", function(l, str, r)
return l..highlight(str, "#859900")..r
end)
end
editor.Text = syntax
end)
Nube762
(Nube762)
August 21, 2021, 1:55am
#2
It’s probably because you are changing the TextBox’s text when its Text changes, and that makes a loop.
1 Like
zCrxtix
(zavier)
August 21, 2021, 1:56am
#3
Then how could I fix that?
characters
Nube762
(Nube762)
August 21, 2021, 1:58am
#4
You could use .FocusLost instead of :GetPropertyChangedSignal(“Text”)
nicemike40
(nicemike40)
August 21, 2021, 2:20am
#5
Usually syntax highlighters have one TextBox on top that the player actually types in (but for which the text is invisible) and another text label behind that has all the colors. That way you can listen for text changes on the former while changing the text on the latter.