Printed Text Box Input is Nil

Hey, I am working on my newest plugin, Logs Pro, but theres a problem with printing out the text is in a text box. It just prints “nil” even though there are numbers in the input. I have tried this without the tonumber by the way. Here is a part of the code.

	local Number = math.random(100000, 999999)
	print(Number)
	local rNumber = Number
	print(rNumber)
	
	JoinScreen.Visible = false
	VerifyScreen.Visible = true

	local inputCode = tonumber(VerifyScreen.Input.Text)
	local sumbitCode = VerifyScreen.Submit
	
	sumbitCode.MouseButton1Down:Connect(function()
		print(inputCode)

I have to rush sort of right now, so if anyone could help me, it would be amazing. Thanks!

1 Like

do you have an end statement at the end of ur function, based off the code im assuming it wouldnt work, but assuming you do it seems like it should be okay

1 Like

Have you tried placing the variable inside the event?

local Number = math.random(100000, 999999)
	print(Number)
	local rNumber = Number
	print(rNumber)
	
	JoinScreen.Visible = false
	VerifyScreen.Visible = true

	local sumbitCode = VerifyScreen.Submit
	
	sumbitCode.MouseButton1Down:Connect(function()
        local inputCode = tonumber(VerifyScreen.Input.Text) -- here
		print(inputCode)

This will grab the most current text from the TextBox when the event is fired. What you were doing previously was getting the text when this section of the script initially runs, meaning, it will stay as nil since that’s what the inital textbox text was.

1 Like

yes i do have an end statement

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.