How to detect Text in a Textbox changes

  1. What do you want to achieve?
    Something that can detect if there is text in a textbox, and if there is then it makes a button appear

  2. What is the issue?
    Can’t figure out on how to get it working

  3. What solutions have you tried so far?

if script.Parent.displa.Text ~= "" then
	script.Parent.button.Visible = true
else
	script.Parent.button.Visible = false
end

I have also tried .InputChanged and it didn’t work either

3 Likes

Use .InputChanged to detect changes.

I’ve already tried that, it doesn’t work

You could use TextBox.FocusLost and get the text in the Textbox afterwards.

https://developer.roblox.com/en-us/api-reference/event/TextBox/FocusLost

You can use GetPropertyChangedSignal()

TextBox:GetPropertyChangedSignal("Text"):Connect(function()
      
end
5 Likes

As I’ve mentioned before I already have tried this but it still doesn’t work,
the script is a local script.

You already try with “While wait() do”?

local textbox = script.Parent.TextBox
local button = script.Parent.TextButton
while wait() do
if textbox.Text == “YourText” then
button.Visible = true
else
button.Visible = false
end
end

1 Like

Just tried it and it worked, thank you for your help.

The answer you provided not only freezes the selected thread for an eternity but also does contain an unwanted loop

textbox:GetPropertyChangedSignal("Text"):Connect(function()
    button.Visible = text.Text == "desiredText"
end)
5 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.