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