Hasli4

Untitled

Aug 29th, 2026
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.80 KB | None | 0 0
  1. local ReplicatedStorage = game:GetService("ReplicatedStorage")
  2.  
  3. local openNameInput = ReplicatedStorage:WaitForChild("OpenNameInput")
  4. local submitPlayerName = ReplicatedStorage:WaitForChild("SubmitPlayerName")
  5.  
  6. local gui = script.Parent
  7. local frame = gui:WaitForChild("Frame")
  8.  
  9. local textBox = frame:WaitForChild("TextBox")
  10. local confirmButton = frame:WaitForChild("ConfirmButton")
  11.  
  12. gui.Enabled = false
  13.  
  14. --------------------------------------------------
  15. -- Открытие окна
  16. --------------------------------------------------
  17.  
  18. openNameInput.OnClientEvent:Connect(function(responseText)
  19.  
  20. -- Если сервер прислал готовый ответ NPC,
  21. -- значит имя уже успешно сохранено.
  22. if responseText then
  23.  
  24. gui.Enabled = false
  25.  
  26. -- Здесь потом можно продолжить диалог.
  27. print("NPC:", responseText)
  28.  
  29. return
  30. end
  31.  
  32. -- Открываем ввод имени
  33. gui.Enabled = true
  34.  
  35. textBox.Text = ""
  36. textBox:CaptureFocus()
  37. end)
  38.  
  39. --------------------------------------------------
  40. -- Отправка имени
  41. --------------------------------------------------
  42.  
  43. local function submitName()
  44.  
  45. local name = textBox.Text
  46.  
  47. name = name:match("^%s*(.-)%s*$")
  48.  
  49. if name == "" then
  50. return
  51. end
  52.  
  53. -- Отправляем имя серверу
  54. submitPlayerName:FireServer(name)
  55.  
  56. gui.Enabled = false
  57. end
  58.  
  59. --------------------------------------------------
  60. -- Кнопка OK
  61. --------------------------------------------------
  62.  
  63. confirmButton.Activated:Connect(submitName)
  64.  
  65. --------------------------------------------------
  66. -- Enter в TextBox
  67. --------------------------------------------------
  68.  
  69. textBox.FocusLost:Connect(function(enterPressed)
  70.  
  71. if enterPressed then
  72. submitName()
  73. end
  74.  
  75. end)
Advertisement
Add Comment
Please, Sign In to add comment