Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local ReplicatedStorage = game:GetService("ReplicatedStorage")
- local openNameInput = ReplicatedStorage:WaitForChild("OpenNameInput")
- local submitPlayerName = ReplicatedStorage:WaitForChild("SubmitPlayerName")
- local gui = script.Parent
- local frame = gui:WaitForChild("Frame")
- local textBox = frame:WaitForChild("TextBox")
- local confirmButton = frame:WaitForChild("ConfirmButton")
- gui.Enabled = false
- local submitting = false
- --------------------------------------------------
- -- Открытие окна ввода имени
- --------------------------------------------------
- openNameInput.OnClientEvent:Connect(function()
- gui.Enabled = true
- textBox.Text = ""
- submitting = false
- textBox:CaptureFocus()
- end)
- --------------------------------------------------
- -- Отправка имени
- --------------------------------------------------
- local function submitName()
- if submitting then
- return
- end
- local name = textBox.Text
- -- Убираем пробелы в начале и конце
- name = name:match("^%s*(.-)%s*$")
- -- Пустое имя не принимаем
- if name == "" then
- return
- end
- submitting = true
- -- Передаём имя серверу
- submitPlayerName:FireServer(name)
- end
- --------------------------------------------------
- -- Нажатие кнопки
- --------------------------------------------------
- confirmButton.Activated:Connect(function()
- submitName()
- end)
- --------------------------------------------------
- -- Enter в TextBox
- --------------------------------------------------
- textBox.FocusLost:Connect(function(enterPressed)
- if enterPressed then
- submitName()
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment