Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local textBox = script.Parent.TextBox
- local Frame = script.Parent
- local ReplicatedStorage = game:GetService("ReplicatedStorage")
- local CheckSecretCode =
- ReplicatedStorage:WaitForChild("CheckSecretCode")
- -- =====================================================
- -- ЦВЕТА
- -- =====================================================
- local colorNormal = Color3.new(1, 1, 1)
- local colorWrong = Color3.new(1, 0, 0)
- local colorCorrect = Color3.new(0, 1, 0)
- -- =====================================================
- -- НАСТРОЙКА TEXTBOX
- -- =====================================================
- textBox.ClearTextOnFocus = true
- textBox.Text = ""
- textBox.Font = Enum.Font.Code
- textBox.PlaceholderText = "Введи секретный код"
- textBox.BackgroundColor3 = colorNormal
- -- =====================================================
- -- КОГДА TEXTBOX ПОЛУЧИЛ ФОКУС
- -- =====================================================
- local function onFocused()
- textBox.BackgroundColor3 = colorNormal
- end
- -- =====================================================
- -- КОГДА ВВОД ЗАКОНЧЕН
- -- =====================================================
- local function onFocusLost(
- enterPressed,
- inputObject
- )
- if not enterPressed then
- textBox.Text = ""
- textBox.BackgroundColor3 =
- colorNormal
- return
- end
- -- Получаем введённый текст
- local guess = textBox.Text
- -- Отправляем его серверу
- CheckSecretCode:FireServer(guess)
- end
- -- =====================================================
- -- ПОЛУЧАЕМ РЕЗУЛЬТАТ ОТ СЕРВЕРА
- -- =====================================================
- CheckSecretCode.OnClientEvent:Connect(
- function(isCorrect)
- if isCorrect then
- -- Правильный код
- textBox.Text = "Ответ верный"
- textBox.BackgroundColor3 =
- colorCorrect
- task.wait(4)
- Frame.Visible = false
- else
- -- Неправильный код
- textBox.Text = "Неверный код"
- textBox.BackgroundColor3 =
- colorWrong
- task.wait(4)
- Frame.Visible = false
- end
- end
- )
- -- =====================================================
- -- СОБЫТИЯ
- -- =====================================================
- textBox.FocusLost:Connect(
- onFocusLost
- )
- textBox.Focused:Connect(
- onFocused
- )
Advertisement
Add Comment
Please, Sign In to add comment