Hello dear scriptinghelpers community. I am doing an login system but TextBox .Text always return an empty String:
local username = script.Parent.UserName.Text print(username)
->
How can I fix that?
local username = script.Parent.UserName username.Changed:connect(function() print(username.Text) end)
To make it change whenever the text changes do:
local Username script.Parent.UserName.Changed:Connect(function() Username = script.Parent.UserName.Text end)
function TextEnded() local username = script.Parent.UserName.Text -- Change the username variable into the text print(username) -- Prints the username end script.Parent.UserName.FocusLost:connect(TextEnded) -- This activates when the player stops interacting with the TextBox.
You can use the FocusLost function to change the username variable.