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