Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

TextBox GUI Script, Help Please?

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

'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)

3 comments

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...

0

Follow it from the script then.

0

I actually figured this out, so I'm good. Thanks for trying to help, though.

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.

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

This discussion is preserved as it was. New answers, comments, and votes are closed.