|
| 30 Apr 2016 07:10 AM |
I have a empty textbox GUI. If I typed the word "COLOR" inside it and pressed enter, something will happen. how do I make it that if I clicked enter, something will happen?
this is more like a pass word. I must write it then click enter. |
|
|
| Report Abuse |
|
|
Erediin
|
  |
| Joined: 13 Mar 2016 |
| Total Posts: 756 |
|
|
| 30 Apr 2016 07:42 AM |
i'm a bit special but I believe it'd be something like:
if game.StarterGui.UI.Frame.Textbox.Text = ("COLOR") then
(code)
end
I'm a beginner though so I'm not too sure.
|
|
|
| Report Abuse |
|
|
|
| 30 Apr 2016 08:44 AM |
that's what I don't want.
I don't want it that while I finish typing color it automatically runs the other script. I want to write 'color' then CLICK enter.
|
|
|
| Report Abuse |
|
|
|
| 30 Apr 2016 08:53 AM |
first of all don't do 'game.startergui', just make a localscript inside of a frame with a textbox and textbutton with a mousebutton1click event hooked up to the button to check the text of the textbox
|
|
|
| Report Abuse |
|
|
|
| 30 Apr 2016 09:05 AM |
i don't want a button that says if textbox.text = color then bla bla bla
I want the textbox alone if I write the keyword and click enter. |
|
|
| Report Abuse |
|
|
|
| 30 Apr 2016 09:05 AM |
| Pressing enter usually makes you lose focus of the text box so you could try running the function every time is lost on the text box, then combine that with an if statement checking what the text in the text box is. |
|
|
| Report Abuse |
|
|
|
| 30 Apr 2016 09:06 AM |
You need a MouseButton1Click event for a TextButtin if you want anything to happen when you click something
|
|
|
| Report Abuse |
|
|
|
| 30 Apr 2016 09:06 AM |
And if you meant "press enter" instead of "click enter" then shame on you for not being clear. Use the FocusLost event of a TextButton
|
|
|
| Report Abuse |
|
|
| |
|
|
| 30 Apr 2016 09:08 AM |
was directed at OP not you ^
|
|
|
| Report Abuse |
|
|
Erediin
|
  |
| Joined: 13 Mar 2016 |
| Total Posts: 756 |
|
|
| 30 Apr 2016 09:16 AM |
I was just doing that as an example Recurring, I wasn't really thinking anything through.
|
|
|
| Report Abuse |
|
|
|
| 30 Apr 2016 09:22 AM |
its ok just wanted to let you know never reference game.StarterGui when scripting GUIs if you didn't know it already...more info here:
https://www.youtube.com/watch?v=txcHH11-3v8
|
|
|
| Report Abuse |
|
|
|
| 30 Apr 2016 09:44 AM |
here's an example of a script.
if script.Parent.TextBox1.Text = "color" then script.Parent.TextButton1.Visible = true
in this script, if I type the word color it will immediately show me the textbutton. what I want is that when I type the word color nothing happens, I need to press the "ENTER" key for the textbutton to be visible. |
|
|
| Report Abuse |
|
|
|
| 30 Apr 2016 09:48 AM |
script.Parent.TextBox1.FocusLost:connect(function(enter) if enter and script.Parent.TextBox1.Text = "color" then --Turns out FocusLost even has an argument for the Enter Key. end end) |
|
|
| Report Abuse |
|
|
Crimsonal
|
  |
| Joined: 23 Apr 2011 |
| Total Posts: 1795 |
|
|
| 30 Apr 2016 09:54 AM |
script.Parent.TextBox1.FocusLost:connect(function(enter) if enter and script.Parent.TextBox1.Text:lower() == "color" then
-- do stuff
end
end) |
|
|
| Report Abuse |
|
|
|
| 30 Apr 2016 10:20 AM |
script.Parent.TextBox1.FocusLost:connect(function(enter) if enter and script.Parent.TextBox1.Text:lower() == "color" then TextButton.Visible = true
end
end)
didn't work? |
|
|
| Report Abuse |
|
|
|
| 30 Apr 2016 10:21 AM |
script.Parent.TextBox1.FocusLost:connect(function(enter) if enter and script.Parent.TextBox1.Text:lower() == "color" then script.ParentTextButton.Visible = true
end
end)
-sorry forgot to add script.Parent
but it still doesn't work. |
|
|
| Report Abuse |
|
|
|
| 30 Apr 2016 10:22 AM |
You forgot to add a dot, right?
script.Parent.TextButton.Visible = true |
|
|
| Report Abuse |
|
|
|
| 30 Apr 2016 10:23 AM |
| also, @extreme your script does not work, there is a red line under the '=' between .text = "color" |
|
|
| Report Abuse |
|
|
|
| 30 Apr 2016 10:26 AM |
| I didn't forgot to add a dot, I just typed it wrong in the thread. |
|
|
| Report Abuse |
|
|
|
| 30 Apr 2016 10:27 AM |
Mb, forgot an =
script.Parent.TextBox1.FocusLost:connect(function(enter) if enter and script.Parent.TextBox1.Text == "color" then --Turns out FocusLost even has an argument for the Enter Key. end end)
Should work now c: |
|
|
| Report Abuse |
|
|
| |
|
Crimsonal
|
  |
| Joined: 23 Apr 2011 |
| Total Posts: 1795 |
|
|
| 30 Apr 2016 02:11 PM |
| you're doing something wrong because I just tested it and it worked fine. It's something on your part |
|
|
| Report Abuse |
|
|
|
| 30 Apr 2016 02:38 PM |
oh, it actually works. I forgot to change TextBox1 in the script to the actual name of the textbox.
thanks! |
|
|
| Report Abuse |
|
|