Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How can I detect a specific word using Textboxes?

Asked by 3 years ago
Edited 3 years ago

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

Log in to vote
0
Answered by 3 years ago

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)
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? ArtFoundation 255 — 3y
0
Ill try it, thanks xd_Lxcifer -3 — 3y
Ad

Answer this question