Keypad Numbers System

I am trying to make it to where you press 1 twice, it states 11 on the display instead of just the 1, as in doing a test for stacking other numbers into a code for like 2521 for example, any ideas?

screen = script.Parent.Display.SurfaceGui.KeyText
combination = script.Parent.Combination
numbers = script.Parent.Numbers
n1 = script.Parent.N1
n2 = script.Parent.N2
n3 = script.Parent.N3
n4 = script.Parent.N4

numbers.Changed:Connect(function()
	screen.Text = numbers.Value
end)

n1.ClickDetector.MouseClick:Connect(function()
	numbers.Value = "1"
end)
2 Likes

Try

n1.ClickDetector.MouseClick:Connect(function()
	numbers.Value = numbers.Value .. "1"
end)
 
1 Like

KeyPad.rbxm (14.1 KB)
(also secure)

Good Luck with your game!
Add: KeyPad script change
(handles over entrees)

snippet
for i = 0, 9 do
	buttons:WaitForChild(i).ClickDetector.MouseClick:Connect(function()
		press:Play() input = input .. tostring(i)
		if string.len(input) < 5 then
			inputLabel.Text = input
		else ClearCode()
		end
	end)
end

function ClearCode()
	input = "" inputLabel.Text = "****"
end

function EnterCode()
	if input == correctCode then enter:Play()
		inputLabel.Text = " Access "
		-- they got it, do whatever

		task.wait(1)
	else inputLabel.Text = "****"
	end	task.wait(1)
	ClearCode()
end

enterButton.ClickDetector.MouseClick:Connect(EnterCode)
clearButton.ClickDetector.MouseClick:Connect(ClearCode)
local p = script.Parent
local screen = p.Display.SurfaceGui.KeyText
local combination = p.Combination
local numbers = p.Numbers
local keypad = {p.N0, p.N1, p.N2, p.N3, p.N4, p.N5, p.N6, p.N7, p.N8, p.N9}

numbers.Changed:Connect(function(val)
	screen.Text = val
end)

for _, v in keypad do
    v.ClickDetector.MouseClick:Connect(function()
        if screen.Text:len() == 4 then return end
        numbers.Value = numbers.Value..string.split(v.Name, "N")
    end)
end

I never really understood for i, in pairs, can you explain this script a bit more in detail?

1 Like

In the table above it is a listing of buttons. This simply runs through them all.
( i ) is a counter and the rest is setting up functions for each …

can you describe this script and it’s functions?

Honestly I just need to know how for i loops in pairs work, and how the tables work too and I think id be able to do this too

1 Like

Sorry, I was a bit tired last night, Hope this makes up for it.
Forget that nightmare scratch script … Added a download.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.