Hasli4

Untitled

Aug 12th, 2026 (edited)
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1.  
  2. local textBox = script.Parent.TextBox
  3. local Frame = script.Parent
  4.  
  5. local ReplicatedStorage = game:GetService("ReplicatedStorage")
  6. local CheckSecretCode = ReplicatedStorage:WaitForChild("CheckSecretCode")
  7.  
  8. local colorNormal = Color3.new(1, 1, 1)
  9. local colorWrong = Color3.new(1, 0, 0)
  10. local colorCorrect = Color3.new(0, 1, 0)
  11.  
  12. -- Настройка TextBox
  13. textBox.ClearTextOnFocus = true
  14. textBox.Text = ""
  15. textBox.Font = Enum.Font.Code
  16. textBox.PlaceholderText = "Введи секретный код"
  17. textBox.BackgroundColor3 = colorNormal
  18.  
  19. -- Когда игрок нажал на TextBox
  20. local function onFocused()
  21. textBox.BackgroundColor3 = colorNormal
  22. end
  23.  
  24. -- Когда игрок закончил ввод
  25. local function onFocusLost(enterPressed, inputObject)
  26.  
  27. if enterPressed then
  28.  
  29. local guess = textBox.Text
  30.  
  31. -- Отправляем введённый код серверу
  32. CheckSecretCode:FireServer(guess)
  33.  
  34. else
  35.  
  36. textBox.Text = ""
  37. textBox.BackgroundColor3 = colorNormal
  38.  
  39. end
  40. end
  41.  
  42. -- Получаем результат от сервера
  43. CheckSecretCode.OnClientEvent:Connect(function(isCorrect)
  44.  
  45. if isCorrect then
  46.  
  47. textBox.Text = "Ответ верный"
  48. textBox.BackgroundColor3 = colorCorrect
  49.  
  50. task.wait(4)
  51.  
  52. Frame.Visible = false
  53.  
  54. else
  55.  
  56. textBox.Text = "Неверный код"
  57. textBox.BackgroundColor3 = colorWrong
  58.  
  59. task.wait(4)
  60.  
  61. Frame.Visible = false
  62.  
  63. end
  64.  
  65. end)
  66.  
  67. textBox.FocusLost:Connect(onFocusLost)
  68. textBox.Focused:Connect(onFocused)
  69.  
Advertisement
Add Comment
Please, Sign In to add comment