You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? Keep it simple and clear!
I want to make a code executor in game and I want the text to be color coded like a normal script.
What is the issue? Include screenshots / videos if possible!
The issue is that I can make the executor but the text isn’t color coded like it would in a real script.
The Top Box on the right is supposed to be for code. The bottom box is the output.
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I looked all over the internet and couldn’t find anything.
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.
local something = {["if"] = "rgb(255,0,0)"}
local TextBox = --TextBox Here
TextBox.RichText = true
TextBox.FocusLost:Connect(function()
for i,v in ipairs(something) do
if string.find(TextBox.Text,i) then
TextBox.Text = string.gsub(TextBox.Text,something,"<font color= '"..v.."'>"..i..)
end
end
end)
hmmm, i think this script can help you a bit…your idea!
local Main = script.Parent --The textbox that's player will type their scripts
local Show = Main.Show --The textlabel or something to have color :)
--If only set main,we will have inf loop,inf energy...
local All = {
--[The Name] = "color?",
--Not make sure it's have all
['if'] = '#003ac1',
['local'] = '#003ac1',
['for'] = '#003ac1',
['do'] = '#003ac1',
['string'] = '#a67f00',
['pairs'] = '#a67f00',
['gsub'] = '#a67f00',
['format'] = '#a67f00',
['print'] = '#a67f00',
['true'] = '#007f7f',
['false'] = '#007f7f',
['and'] = '#003ac1',
['then'] = '#003ac1',
['function'] = '#003ac1',
['or'] = '#003ac1',
['OverlapParams'] = 'a67f00',
['new'] = '#a67f00',
['else'] = '#003ac1',
['elseif'] = '#003ac1',
}
--<font color= (Color) > (String) </font>
Main.TextTransparency = 1
Main:GetPropertyChangedSignal('Text'):Connect(function()
Show.RichText = true --Set true for color,important [:
Show.Text = Main.Text
local M = Main.Text
for i,v in pairs(All) do
M = string.gsub(M,i,string.format('<font color=%q>%s</font>',v,i))
--string.gsub('if fun then fly','if','<font color=#003ac1>if</font>')
--^^Replace strings
Show.Text = M
end
end)