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

Text boxes are not detecting an input that a player has put, so is it possible to fix?

I am trying to have a text box set the text of a text label in workspace. Every time I press the submit button, it puts text, but it is the text that is in the text box before I typed anything, which was no text at all. Is there any way to fix this problem? Thanks! My script is below.

local Gate = script.Parent.Parent.Parent.Parent.Gate.Value
function onClick()
	game.Workspace["GateSet"..Gate].GateBG.TV.SurfaceGui.Frame.Destination.DESTVALUE.Text = script.Parent.Parent.NameBox.Text
	script.Parent.Text = "Success!"
	wait(2)
	script.Parent.Text = "Submit"
	script.Parent.Parent.Visible = false
	script.Parent.Parent.Parent.MainMenu.Visible = true
end
script.Parent.MouseButton1Down:connect(onClick)

3 comments

0

What does script.Parent.Parent.Parent.Parent refer to?

0

Don't use MouseButton1Down, you should use FocusLost

0

script.Parent.Parent.Parent.Parent refers to the main frame of the GUI that holds all the frames (screens)

1 answer

✓ Accepted answer

That script is a mess so i'll write you a mock-up really quick. There is a property called FocusLost that deals with inputting text. The input ends when the player clicks off the textbox/stops typing.

local TextBox = script.Parent.Parent:WaitForChild("TextBox")
local TextLabel = script.Parent.Parent:WaitForChild("TextLabel")

TextBox.FocusLost:Connect(function()
	local text = TextBox.Text
	TextLabel.Text = text
end)

Also you shouldn't be using connect, use Connect instead. It's deprecated.

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