Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How can I detect a specific word using Textboxes?

I am trying to make an image change its color by typing a text in a text box such as "Red" or "Blue". But I do not know what functions to use. I've tried Player.Chatted and GetPropertyChangedSignal.

1 answer

✓ Accepted answer

You could use the InputChanged event of a TextBox to run your code when the text is altered. Using that you could either create a dictionary correlating all the available strings into colors or a more limited option you could use BrickColors and convert that to a Color3 value.

local Colors = {
	red = Color3.fromRGB(255, 0, 0),
	green = Color3.fromRGB(0, 255, 0),
	blue = Color3.fromRGB(0, 0, 255),
}

TextBox.InputChanged:Connect(function()
	local Color = Colors[TextBox.Text:lower()]
	
	if Color then
		ImageLabel.Color = Color
	end
end)

2 comments

0

Why would you want to use InputChanged over FocusLost? Are you expecting the player to use something but a keyboard to enter a word?

0

Ill try it, thanks

This discussion is preserved as it was. New answers, comments, and votes are closed.