Hasli4

Untitled

Aug 31st, 2026
21
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.56 KB | None | 0 0
  1. local ReplicatedStorage = game:GetService("ReplicatedStorage")
  2.  
  3. local submitPlayerName = ReplicatedStorage:WaitForChild("SubmitPlayerName")
  4.  
  5. local gui = script.Parent
  6. local frame = gui:WaitForChild("Frame")
  7.  
  8. local textBox = frame:WaitForChild("TextBox")
  9. local confirmButton = frame:WaitForChild("ConfirmButton")
  10.  
  11. local dialog = workspace:WaitForChild("NPC")
  12. :WaitForChild("Head")
  13. :WaitForChild("Dialog")
  14.  
  15. local nameChoice = dialog:WaitForChild("NameChoice")
  16.  
  17.  
  18. --------------------------------------------------
  19. -- Начальное состояние
  20. --------------------------------------------------
  21.  
  22. gui.Enabled = false
  23.  
  24. local submitting = false
  25.  
  26.  
  27. --------------------------------------------------
  28. -- ПРОВЕРКА ЗАПУСКА
  29. --------------------------------------------------
  30.  
  31. print("[NAME GUI] LocalScript запустился")
  32. print("[NAME GUI] Dialog найден:", dialog:GetFullName())
  33. print("[NAME GUI] NameChoice найден:", nameChoice:GetFullName())
  34.  
  35.  
  36. --------------------------------------------------
  37. -- Отслеживаем выбор DialogChoice
  38. --------------------------------------------------
  39.  
  40. dialog.DialogChoiceSelected:Connect(function(player, choice)
  41.  
  42. print("========================================")
  43. print("[NAME GUI] DialogChoiceSelected сработал")
  44. print("[NAME GUI] Игрок:", player.Name)
  45. print("[NAME GUI] Выбранный Choice:", choice.Name)
  46. print("[NAME GUI] UserDialog:", choice.UserDialog)
  47. print("========================================")
  48.  
  49.  
  50. --------------------------------------------------
  51. -- В LocalScript player должен быть нашим игроком
  52. --------------------------------------------------
  53.  
  54. if player ~= game.Players.LocalPlayer then
  55. return
  56. end
  57.  
  58.  
  59. --------------------------------------------------
  60. -- Проверяем, что выбрали именно NameChoice
  61. --------------------------------------------------
  62.  
  63. if choice ~= nameChoice then
  64. return
  65. end
  66.  
  67.  
  68. print("[NAME GUI] Выбран именно NameChoice!")
  69.  
  70.  
  71. --------------------------------------------------
  72. -- Открываем окно
  73. --------------------------------------------------
  74.  
  75. gui.Enabled = true
  76.  
  77. textBox.Text = ""
  78.  
  79. submitting = false
  80.  
  81. textBox:CaptureFocus()
  82.  
  83. print("[NAME GUI] NameInputGui открыт")
  84.  
  85. end)
  86.  
  87.  
  88. --------------------------------------------------
  89. -- Отправка имени
  90. --------------------------------------------------
  91.  
  92. local function submitName()
  93.  
  94. if submitting then
  95. return
  96. end
  97.  
  98. local name = textBox.Text
  99.  
  100. -- Убираем пробелы
  101. name = name:match("^%s*(.-)%s*$")
  102.  
  103. -- Пустое имя нельзя отправить
  104. if name == "" then
  105. print("[NAME GUI] Имя пустое")
  106. return
  107. end
  108.  
  109. submitting = true
  110.  
  111. print("[NAME GUI] Отправляем имя серверу:", name)
  112.  
  113. submitPlayerName:FireServer(name)
  114.  
  115. -- Пока сервер обрабатывает имя,
  116. -- окно можно скрыть
  117. gui.Enabled = false
  118.  
  119. end
  120.  
  121.  
  122. --------------------------------------------------
  123. -- Кнопка
  124. --------------------------------------------------
  125.  
  126. confirmButton.Activated:Connect(function()
  127.  
  128. print("[NAME GUI] Нажата кнопка ConfirmButton")
  129.  
  130. submitName()
  131.  
  132. end)
  133.  
  134.  
  135. --------------------------------------------------
  136. -- Enter
  137. --------------------------------------------------
  138.  
  139. textBox.FocusLost:Connect(function(enterPressed)
  140.  
  141. if enterPressed then
  142.  
  143. print("[NAME GUI] Нажат Enter")
  144.  
  145. submitName()
  146.  
  147. end
  148.  
  149. end)
Advertisement
Add Comment
Please, Sign In to add comment