Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
22To 70
9 years ago

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
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. LetThereBeCode 360 — 9y

1 answer

Log in to vote
1
Answered by 9 years ago

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.

0
where would this go in the script? 22To 70 — 9y
0
Wherever. Just make sure you sort out the undeclared variables and read from curr instead of textBox.Text User#6546 35 — 9y
Ad

Answer this question