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

TextBox GUI Script, Help Please?

Asked by 10 years ago

I'm trying to make a script that relays whatever the user inputs into the TextBox GUI back to the player via print(" "). The code that I have tried so far is:

player_input = script.Parent.Parent.TextBox.Text

function submit()
print("Hello, " .. player_input)
end

script.Parent.MouseButton1Down:connect(submit)

Can anyone fix my errors?

3 answers

Log in to vote
0
Answered by
hiccup111 231 Moderation Voter
10 years ago

'player_input' needs updating in the submit function.


function submit() player_input = script.Parent.Parent.TextBox.Text print("Hello, " .. player_input) end script.Parent.MouseButton1Down:connect(submit)
0
Thanks, but this does not work. I think my error is in the variable "player_input". I don't know that "script.Parent.Parent.TextBox.Text" is the correct path... alienantics 15 — 10y
0
Follow it from the script then. hiccup111 231 — 10y
0
I actually figured this out, so I'm good. Thanks for trying to help, though. alienantics 15 — 10y
Ad
Log in to vote
0
Answered by
Damo999 182
10 years ago

Here is what the hierarchy looks like for me

-StarterGui
    -ScreenGui
        -TextBox
        -Textbutton
            -Script

The above script was not wrong you may have had the wrong hierarchy setup.

Log in to vote
0
Answered by 10 years ago

Sorry if this didn't help.

player_input = script.Parent.Parent:FindFirstChild("TextBox") --Find TextBox

function submit() --The Function
if player_input~=nil then --If TextBox exists
print("Hello, " .. player_input.Text) --Prints
elseif not player_input~=nil then --If TextBox doesn't exist
print("Error, player_input doesn't exist") --Prints it doesn't
end end --All the ends for the if, function, and/or for loops
script.Parent.MouseButton1Down:connect(submit) --The Event

Answer this question