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

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

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

✓ Accepted answer

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.

3 comments

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

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!

0

Glad to be able to help! ????

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