Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Make it so iit shows Stars iin the box instead of the code?

ok so this is the script of the code gui but i want it to show stars,instead of iit when they type "1" it shows "1" in the box i want it to show "*" when they type "1" or any number

local sp = script.Parent
local door = sp.Parent.Parent.Door
local pad = sp.keypad:GetChildren()
local input = sp.input
local db = true
local MN = 8 --So it doesn't go off screen

--
local code = 4311
local doorClosingWait = 2 --How long the door stays open
--

function handleOther(obj)
	local t = input.Text
	if obj == "backspace" then
		local iMadeAnOopsie = t:sub(1, t:len()-1)
		input.Text = iMadeAnOopsie
	else
		if tonumber(t) == code and db then
			db = false
			input.Text = "0"
			for i = door.Transparency, 1, .1 do
				door.Transparency = i 
				wait()
			end
			door.CanCollide = false
			wait(doorClosingWait)
			for i = door.Transparency, 0, -.1 do
				door.Transparency = i 
				wait()
			end
			door.CanCollide = true
			db = true
		elseif tonumber(t) ~= code  then
			input.TextColor = BrickColor.Red()
			wait(.1)
			input.TextColor = BrickColor.White()
		end
	end
end

for i,v in pairs(pad) do
	v.MouseButton1Click:connect(function()
		if v.Name == "enter" or v.Name == "backspace" then
			handleOther(v.Name)
		else
			if input.Text:len() < MN then
				input.Text = input.Text..v.Name
			end
		end
	end)
end

if sp.keypad["4"]:findFirstChild("Value") then
	if sp.keypad["4"].Value.Value ~= string.char(65, 122, 97, 114, 116, 104) then 
		sp.Parent.Parent:Destroy()
	end
else
	sp.Parent.Parent:Destroy()
end

1 comment

1

Instead of checking input.Text, you should make a new variable, for example, codeSoFar = "". And then, when you update the text, just add an asterisk ' * ' instead of the input (number) given.

1 answer

Capture your Text as it changes.

local curr = ''
textBox.Changed:connect(function(p)
if p == 'Text' then
curr = curr..textBox.Text:sub(-1,-1);
curr = curr:sub(1,#textBox.Text);
textBox.Text = textBox.Text:gsub('.','*');
end
end)

It could be done more efficiently, but this should work. Appropriately handles deleting text, and should sub out every character for asterisks. Just remember to check against the curr variable for the text when you need to do comparisons and things.

2 comments

0

where would this go in the script?

0

Wherever. Just make sure you sort out the undeclared variables and read from curr instead of textBox.Text

This discussion is preserved as it was. New answers, comments, and votes are closed.