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

I am trying to use the text of a text box in a server script, it always doesn't detect the text?

here is the script

local box1 = script.Parent.Parent.TextBox

script.Parent.MouseButton1Click:Connect(function()
	print(box1.Text)
end)

2 comments

0

is this a screen gui or a surface gui?

0

Screen

2 answers

Well, I think the problem here is that the variable does not really update with the GUI. So, to make it update, try using a .Changed event to detect if the text has been updated or not. And, I recommend making a separate variable of the "Text" property rather than the whole thing itself. (it makes it easier)

local box = script.Parent.Parent.TextBox -- variable for the box
local boxText = box.Text -- make a separate variable for the text

box.Changed:Connect(function() boxText = box.Text end) -- update the boxText variable each time the text changes

script.Parent.MouseButton1Click:Connect(function()
    print(boxText)
end)

I hope this helps!

You locate the text if it is " ". You just have to locate the text in the function!

local box1

script.Parent.MouseButton1Click:Connect(function()
    box1 = script.Parent.Parent.TextBox
    print(box1.Text)
end)

1 comment

0

And... Dont use numbers for variables :D

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