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

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

Asked by 5 years ago

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)
0
What does script.Parent.Parent.Parent.Parent refer to? User#19524 175 — 5y
0
Don't use MouseButton1Down, you should use FocusLost Vulkarin 581 — 5y
0
script.Parent.Parent.Parent.Parent refers to the main frame of the GUI that holds all the frames (screens) AviaSmxxthy -3 — 5y

1 answer

Log in to vote
0
Answered by
green271 635 Moderation Voter
5 years ago

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.

Ad

Answer this question