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
- --------------------------------------------------
- -- Открытие окна
- --------------------------------------------------
- openNameInput.OnClientEvent:Connect(function(responseText)
- -- Если сервер прислал готовый ответ NPC,
- -- значит имя уже успешно сохранено.
- if responseText then
- gui.Enabled = false
- -- Здесь потом можно продолжить диалог.
- print("NPC:", responseText)
- return
- end
- -- Открываем ввод имени
- gui.Enabled = true
- textBox.Text = ""
- textBox:CaptureFocus()
- end)
- --------------------------------------------------
- -- Отправка имени
- --------------------------------------------------
- local function submitName()
- local name = textBox.Text
- name = name:match("^%s*(.-)%s*$")
- if name == "" then
- return
- end
- -- Отправляем имя серверу
- submitPlayerName:FireServer(name)
- gui.Enabled = false
- end
- --------------------------------------------------
- -- Кнопка OK
- --------------------------------------------------
- confirmButton.Activated:Connect(submitName)
- --------------------------------------------------
- -- Enter в TextBox
- --------------------------------------------------
- textBox.FocusLost:Connect(function(enterPressed)
- if enterPressed then
- submitName()
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment