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?
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)
It works, but only in Localscrpts. That's bad because I can't make Http requests with them.
Well you need to add a remote function/event then.
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.
Text isn't the Text. It's the bool enterpressed. https://developer.roblox.com/api-reference/event/TextBox/FocusLost
My bad, I fixed it
This discussion is preserved as it was. New answers, comments, and votes are closed.
2 comments
The username variable will not update if the text is changed. And these two statements are only going to execute once.
And how can I make it change?