i want to make it so if it find the word sell in the string of text then it makes only that word blue for example. how do i do that
local text = script.Parent.inner.TextBox.Text
if text:find(string.lower("sell")) then -- this only find the word but how do i make it make that word a certain color
print("found")
end
I believe something like this would work, could be new methods, idk
also I heard about a module , because I was searching for a module I found this one , no idea how good or new it is but Rich Text Markup - Roblox
local label = script.Parent
local text = "hehehehaw"
label.Text = text
local term = "hehe"
if term ~= "" then
local split = text:split(term)
if #split - 1 > 0 then
label.Text = table.concat(split, "<font color=\"#00ff00\">"..term.."</font>")
end
end
the output says Maximum event re-entrancy depth exceeded for Instance.Changed (x786)
the instance (textlabel) was only changed once i did a .changed event for when i updated the text
its supposed to see if the text contains the word âsellingâ and if it does it makes that word a certain color
script.Parent.Changed:Connect(function() -- it changes when i update the text
local label = script.Parent
local text = label.Text
local term = "selling"
if term ~= "" then
local split = text:split(term)
if #split - 1 > 0 then
local new = table.concat(split, "<font color=\"#2f38ff\">"..term.."</font>")
label.Text = new
end
end
end)
use this instead, tell me if the error still occurs, I might have to test the script myself then
script.Parent:GetPropertyChangedSignal("Text"):Connect(function()
local label = script.Parent
local text = label.Text
local term = "selling"
if term ~= "" then
local split = text:split(term)
if #split - 1 > 0 then
local new = table.concat(split, "<font color=\"#2f38ff\">"..term.."</font>")
label.Text = new
end
end
end)
Well, the way this works, is when the text of the script.parent changes it runs this function.
make sure this code is in a local script inside a object that has a text property for ex, textbox or label
script.Parent:GetPropertyChangedSignal("Text"):Connect(function()
local label = script.Parent
local text = label.Text
local term = "selling"
if term ~= "" then
local split = text:split(term)
if #split - 1 > 0 then
local new = table.concat(split, "<font color=\"#2f38ff\">"..term.."</font>")
label.Text = new
end
end
end)