How i can make script syntax color in text box?

Hello, i’m making script executor and require for roblox, i finshed everything with protection but i want to know how i can make the script syntax color in the text of my text box ? (local script) and have the original script in a variable or Value for exemple. Im not too advanced to do that then i ask for help here, thanks. (Script like in studio but text box)

1 Like

If you go to a text box’s properties there is a way to customize the text and color TextBox Properties>Text>Font, TextColor, etc.
Hope this is what you were looking for

1 Like

You can use this module,

And store it anywhere inside your gui or ReplicatedStorage and require it.

local syntax = require(game.ReplicatedStorage:WaitForChild("Syntax"))

After that, just call this function:

syntax(Your textbox)

Hope this helps.

You can use RichText on your TextBox. Unfortunately, this only applies when you click off of the TextBox.

Official Documentation on RichText

Nope, not the text color i mean like your script a script on studio the color syntax of lua.

If you want it to be the same as the colour syntax of Lua, you can still use rich text as stated above. What are you using this for?

yea but for the module i got the error below,
Source is not a valid member of TextBox “Players.hollaquetalBRUH.PlayerGui.ScreenGui.Frame.TextBox” - Client - Syntax:24

Read through the module script and see how it works. You need to debug it or make sure you are using it correctly.

return function(EditorFrame)
	local Source = EditorFrame.Source
	local Lines = EditorFrame.Lines

That what i don’t understand i need to require with the frame, text box or text ?

I am unsure what the property “Lines” is.
I would assume that there is more code in the function. What else does it say?

The only thing for “Lines” is

local lin = 1
			s:gsub("\n", function()
				lin = lin + 1
Lines.Text = ""
			for i = 1, lin do
				Lines.Text = Lines.Text .. i .. "\n"

All the script does is line separation, which is not syntax colour.
Please be more specific about what you are trying to achieve. I suggest that you provide an example.

Here, i want ot make the color of that but for a text box. (script syntax color)

If you want that, you will have to create a system that separates words, identifies them and adds the correct colour. As stated above by another developer, you should be using RichText.
You could separate the words by using

local keywords = {"string", "function", "end"} -- All the keywords you want registered.
local text = "string function end" -- A random string containing keywords.
local stringTable = string.split(text, " ") -- The keywords split into a table. Example: stringTable[1] = "string" and all the other words that have been split.

After you do that, you can make a loop that loops through the stringTables.
As stated above, you can then surround the text with a RichText code.

1 Like