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 enterPressed then
- local guess = textBox.Text
- -- Отправляем введённый код серверу
- CheckSecretCode:FireServer(guess)
- else
- textBox.Text = ""
- textBox.BackgroundColor3 = colorNormal
- end
- 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