✓ Accepted answer
Hello!
I remember when I attempted to do the exact same thing, when people would enter a password to continue, and then hide their input (or mask it) by having "*" instead of the characters the users had entered.
Now, I thought of the same solution as you, by changing the actual TextBox, however, it just turned up to be buggy, and after a while of thinking I got a solution where I simply had a TextLabel above the TextBox by having the TextLabel's ZIndex higher than the TextBox.
Simply:
- create TextLabel and have exact same size and position (if you want to..)
- set the TextLabel's ZIndex to one higher than the TextBox, then you won't be able to see the characters in the TextBox
Then, create a script that edits the TextLabel's text based on amount of characters in the TextBox.
A simple variant:
local PasswordInput = script.Parent.PasswordInput;
local PasswordMask = script.Parent.PasswordMask;
PasswordInput:GetPropertyChangedSignal("Text"):Connect( function ()
local currentPasswordInput = PasswordInput.Text;
PasswordMask.Text = ("*"):rep(#currentPasswordInput);
end)
That's a simple hacky solution, which in my opinion is better than changing the actual TextBox.
I hope this helped, if you have any questions, please ask!
5 comments
ok why use semicolons in a language totally irrelevant to JavaScript
other languages besides javascript use it aswell :p
ok, but this is pointless because semicolons in Lua are used for writing code on the same line not multiple lines
Some people do it out of habit from languages such as say C++, Lua is very flexible and can work with semicolons.
Semicolons are not just useless in Lua, there are some usecases where you actually need semicolons, such as using anonymous functions. There is nothing wrong with using semicolons, and I originally ignored your post due to this, I thought you knew this but apparently not.