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

How to get TextBox.Text instead of a blank space?

Asked by 2 years ago

I've tried to get the text of a box using textbox.Text. After some debugging I found out the text it gets is just blank space. The local script is in a "Submit" button that sends the text through a remote event.

local submit = script.Parent
local textbox = game.StarterGui.ScreenGUI.Tab:WaitForChild("input")
local input = textbox.Text
local remevent= game.ReplicatedStorage:WaitForChild("RemEvent")

submit.MouseButton1Click:Connect(function()
    remevent:FireServer(input)
    print(input)
end)

1 answer

Log in to vote
1
Answered by 2 years ago

The reason is because the input is the variable from before the player clicked the button. This should be the code

local submit = script.Parent
local textbox = game.StarterGui.ScreenGUI.Tab:WaitForChild("input")
local remevent= game.ReplicatedStorage:WaitForChild("RemEvent")

submit.MouseButton1Click:Connect(function()
    local input = textbox.Text
    remevent:FireServer(input)
    print(input)
end)

This should work because it is the input from when the player clicked the button.

0
It makes a lot of sense but still didn't work ???? I still get blank space in the output. I'm using print(input) to check Mafincho 43 — 2y
0
It's me again, I fixed it! All I had to do is change game.StarterGui.ScreenGUI.Tab:WaitForChild("input") to script.Parent.Parent:WaitForChild("input") Your answer also helped me A LOT! Mafincho 43 — 2y
0
Glad to be able to help! ???? mariohead13 129 — 2y
Ad

Answer this question