Advertisement
HowToRoblox

KeypadHandler

Apr 9th, 2021
2,679
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.94 KB | None | 0 0
  1. local door = script.Parent.Parent.Parent.Door
  2.  
  3.  
  4. local input = script.Parent.InputtedCode
  5.  
  6. local buttons = script.Parent.ButtonsBG
  7.  
  8.  
  9. local code = "2471"
  10. local currentCode = ""
  11.  
  12. input.Text = currentCode
  13.  
  14.  
  15.  
  16. for i, button in pairs(buttons:GetChildren()) do
  17.    
  18.    
  19.     button.MouseButton1Click:Connect(function()
  20.        
  21.         if tonumber(button.Name) then
  22.            
  23.             currentCode = currentCode .. button.Name
  24.             input.Text = currentCode
  25.            
  26.            
  27.         elseif button.Name == "Reset" then
  28.            
  29.             currentCode = ""
  30.             input.Text = currentCode
  31.            
  32.            
  33.         elseif button.Name == "Enter" then
  34.            
  35.            
  36.             if currentCode == code then
  37.                
  38.                 currentCode = ""
  39.                
  40.                 input.Text = "Success"
  41.                 door.Transparency = 1
  42.                 door.CanCollide = false
  43.                
  44.                 wait(5)
  45.                
  46.                 input.Text = ""
  47.                 door.Transparency = 0
  48.                 door.CanCollide = true
  49.                
  50.                
  51.             else
  52.                
  53.                 currentCode = ""
  54.                 input.Text = "Incorrect code"
  55.             end
  56.         end
  57.     end)
  58. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement