Hasli4

Untitled

Aug 12th, 2026
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.43 KB | None | 0 0
  1.  
  2. local textBox = script.Parent.TextBox
  3. local Frame = script.Parent
  4.  
  5. local ReplicatedStorage = game:GetService("ReplicatedStorage")
  6.  
  7. local CheckSecretCode =
  8. ReplicatedStorage:WaitForChild("CheckSecretCode")
  9.  
  10.  
  11. -- =====================================================
  12. -- ЦВЕТА
  13. -- =====================================================
  14.  
  15. local colorNormal = Color3.new(1, 1, 1)
  16.  
  17. local colorWrong = Color3.new(1, 0, 0)
  18.  
  19. local colorCorrect = Color3.new(0, 1, 0)
  20.  
  21.  
  22. -- =====================================================
  23. -- НАСТРОЙКА TEXTBOX
  24. -- =====================================================
  25.  
  26. textBox.ClearTextOnFocus = true
  27.  
  28. textBox.Text = ""
  29.  
  30. textBox.Font = Enum.Font.Code
  31.  
  32. textBox.PlaceholderText = "Введи секретный код"
  33.  
  34. textBox.BackgroundColor3 = colorNormal
  35.  
  36.  
  37. -- =====================================================
  38. -- КОГДА TEXTBOX ПОЛУЧИЛ ФОКУС
  39. -- =====================================================
  40.  
  41. local function onFocused()
  42.  
  43. textBox.BackgroundColor3 = colorNormal
  44.  
  45. end
  46.  
  47.  
  48. -- =====================================================
  49. -- КОГДА ВВОД ЗАКОНЧЕН
  50. -- =====================================================
  51.  
  52. local function onFocusLost(
  53. enterPressed,
  54. inputObject
  55. )
  56.  
  57. if not enterPressed then
  58.  
  59. textBox.Text = ""
  60.  
  61. textBox.BackgroundColor3 =
  62. colorNormal
  63.  
  64. return
  65.  
  66. end
  67.  
  68.  
  69. -- Получаем введённый текст
  70. local guess = textBox.Text
  71.  
  72.  
  73. -- Отправляем его серверу
  74. CheckSecretCode:FireServer(guess)
  75.  
  76. end
  77.  
  78.  
  79. -- =====================================================
  80. -- ПОЛУЧАЕМ РЕЗУЛЬТАТ ОТ СЕРВЕРА
  81. -- =====================================================
  82.  
  83. CheckSecretCode.OnClientEvent:Connect(
  84. function(isCorrect)
  85.  
  86. if isCorrect then
  87.  
  88. -- Правильный код
  89. textBox.Text = "Ответ верный"
  90.  
  91. textBox.BackgroundColor3 =
  92. colorCorrect
  93.  
  94. task.wait(4)
  95.  
  96. Frame.Visible = false
  97.  
  98. else
  99.  
  100. -- Неправильный код
  101. textBox.Text = "Неверный код"
  102.  
  103. textBox.BackgroundColor3 =
  104. colorWrong
  105.  
  106. task.wait(4)
  107.  
  108. Frame.Visible = false
  109.  
  110. end
  111.  
  112. end
  113. )
  114.  
  115.  
  116. -- =====================================================
  117. -- СОБЫТИЯ
  118. -- =====================================================
  119.  
  120. textBox.FocusLost:Connect(
  121. onFocusLost
  122. )
  123.  
  124. textBox.Focused:Connect(
  125. onFocused
  126. )
  127.  
Advertisement
Add Comment
Please, Sign In to add comment