How do I detect what the user typed?

Hi everyone! So I have a text box UI, one of those UI’s that allow users to type something inside of the UI, and I’m wondering how to detect what they typed. I’m trying to create a password system. For example, the user enters “Password” which is correct, they get access, if they type anything other than “Password”, block access.

1 Like

You would simply check the TextBox’s Text property. If you wanted to check every time the value changed instead of a submit button, you could also use TextBox:GetPropertyChangedSignal("Text"):Connect(function()
https://developer.roblox.com/en-us/api-reference/property/TextBox/Text

2 Likes

Thank you! The problem here is, when I create a variable to save what the user entered, I can only call the variable inside of the function, here, see.

local Text = script.Parent

local MainGui = script.Parent.Parent

local EnterButton = MainGui.TextButton

Text.PlaceholderText = "Create a Password"

EnterButton.Text = "Create!"

EnterButton.MouseButton1Up:Connect(function()

local PasswordSave = Text.Text

print(PasswordSave)

EnterButton.Text = "Saved Password!"

end)

wait(1)

EnterButton.MouseButton1Up:Connect(function()

if Text.Text =

end)

This should be expected, as the scope of that variable is that function you put it inside. If you needed the value outside of that function, define the value outside or use return to send the value outside of that function.

1 Like