So basically, I want a TextBox that changes the color of the text if it's a certain string. I'm creating a Runtime GUI (basically lets you do stuff while the game is running, like banning people or kicking people from the game) and I want it to be like a script interface that changes color for what you're doing. If you don't understand what I'm saying, create a script, type "print" and you'll see that the color changes. I want that but in a TextBox. Thanks!
By the way, I know that Scripting Helpers isn't a request site, but I have no idea on where to ask this other than Scripting Helpers.
I would use this (if someone has a better option just say)
local WordColorChange = "hello" -- i couldnt think of another variable name script.Parent.Changed:connect(function() -- change script.parent if u have the textbox a variable if script.Parent.Text == WordColorChange then script.Parent.TextColor3= Color3.fromRGB(255,255,255) end end)
you can add more to the list if you choose to. this also sets the text back to the default colour if no keyword was found.
local list = { example = Color3.new(1, 0, 0), -- this example would set the TextColor3 to red (255, 0, 0) if the text was "example" }; local textbox = script.Parent:WaitForChild("TextBox"); textbox.Changed:Connect(function() local success = false; for text, colour in next, list do if (textbox.Text:lower() == text:lower()) then -- remove the ":lower()" on both if you want the text to be case-sensitive textbox.TextColor3 = colour; success = true; break; end end if (not success) then textbox.TextColor3 = Color3.new(); end -- if there was no keyword, set the text back to black. end);