Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local ReplicatedStorage = game:GetService("ReplicatedStorage")
- local submitPlayerName = ReplicatedStorage:WaitForChild("SubmitPlayerName")
- local gui = script.Parent
- local frame = gui:WaitForChild("Frame")
- local textBox = frame:WaitForChild("TextBox")
- local confirmButton = frame:WaitForChild("ConfirmButton")
- local dialog = workspace:WaitForChild("NPC")
- :WaitForChild("Head")
- :WaitForChild("Dialog")
- local nameChoice = dialog:WaitForChild("NameChoice")
- --------------------------------------------------
- -- Начальное состояние
- --------------------------------------------------
- gui.Enabled = false
- local submitting = false
- --------------------------------------------------
- -- ПРОВЕРКА ЗАПУСКА
- --------------------------------------------------
- print("[NAME GUI] LocalScript запустился")
- print("[NAME GUI] Dialog найден:", dialog:GetFullName())
- print("[NAME GUI] NameChoice найден:", nameChoice:GetFullName())
- --------------------------------------------------
- -- Отслеживаем выбор DialogChoice
- --------------------------------------------------
- dialog.DialogChoiceSelected:Connect(function(player, choice)
- print("========================================")
- print("[NAME GUI] DialogChoiceSelected сработал")
- print("[NAME GUI] Игрок:", player.Name)
- print("[NAME GUI] Выбранный Choice:", choice.Name)
- print("[NAME GUI] UserDialog:", choice.UserDialog)
- print("========================================")
- --------------------------------------------------
- -- В LocalScript player должен быть нашим игроком
- --------------------------------------------------
- if player ~= game.Players.LocalPlayer then
- return
- end
- --------------------------------------------------
- -- Проверяем, что выбрали именно NameChoice
- --------------------------------------------------
- if choice ~= nameChoice then
- return
- end
- print("[NAME GUI] Выбран именно NameChoice!")
- --------------------------------------------------
- -- Открываем окно
- --------------------------------------------------
- gui.Enabled = true
- textBox.Text = ""
- submitting = false
- textBox:CaptureFocus()
- print("[NAME GUI] NameInputGui открыт")
- end)
- --------------------------------------------------
- -- Отправка имени
- --------------------------------------------------
- local function submitName()
- if submitting then
- return
- end
- local name = textBox.Text
- -- Убираем пробелы
- name = name:match("^%s*(.-)%s*$")
- -- Пустое имя нельзя отправить
- if name == "" then
- print("[NAME GUI] Имя пустое")
- return
- end
- submitting = true
- print("[NAME GUI] Отправляем имя серверу:", name)
- submitPlayerName:FireServer(name)
- -- Пока сервер обрабатывает имя,
- -- окно можно скрыть
- gui.Enabled = false
- end
- --------------------------------------------------
- -- Кнопка
- --------------------------------------------------
- confirmButton.Activated:Connect(function()
- print("[NAME GUI] Нажата кнопка ConfirmButton")
- submitName()
- end)
- --------------------------------------------------
- -- Enter
- --------------------------------------------------
- textBox.FocusLost:Connect(function(enterPressed)
- if enterPressed then
- print("[NAME GUI] Нажат Enter")
- submitName()
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment