Hi.
I’m trying to create a script that, when the player presses enter after typing specific text in a text box, deletes the text and sets the text in another text box to something else. An example would be if I typed “will it work?” in an input box, and that text would get deleted and “it works!!!” would appear in an output box. My problem is, when I press enter, the text just stays in the box, like the event doesn’t fire (I think it’s cause the game thinks i’m submitting text to a text box and nothing else). All the UserInputService and ContextActionService tutorials I found left me with more questions than answers, so I just tried this
local terminal = script.Parent
local outputBox = terminal.Parent.OutputBox
local output = outputBox.Text
local terminalInput = terminal.Text
function onInput()
if terminalInput == "will it work?" then
terminalInput = ""
output = "it works!!!"
else
terminalInput = ""
output = "invalid command"
end
end
terminal.FocusLost:Connect(onInput)
in a LocalScript and that didn’t work either! If there’s any useful lua knowledge I’m missing, please inform me. Thanks!