Hasli4

Untitled

Aug 30th, 2026
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.69 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. local submitting = false
  15.  
  16.  
  17. --------------------------------------------------
  18. -- Открытие окна ввода имени
  19. --------------------------------------------------
  20.  
  21. openNameInput.OnClientEvent:Connect(function()
  22.  
  23. gui.Enabled = true
  24.  
  25. textBox.Text = ""
  26. submitting = false
  27.  
  28. textBox:CaptureFocus()
  29. end)
  30.  
  31.  
  32. --------------------------------------------------
  33. -- Отправка имени
  34. --------------------------------------------------
  35.  
  36. local function submitName()
  37.  
  38. if submitting then
  39. return
  40. end
  41.  
  42. local name = textBox.Text
  43.  
  44. -- Убираем пробелы в начале и конце
  45. name = name:match("^%s*(.-)%s*$")
  46.  
  47. -- Пустое имя не принимаем
  48. if name == "" then
  49. return
  50. end
  51.  
  52. submitting = true
  53.  
  54. -- Передаём имя серверу
  55. submitPlayerName:FireServer(name)
  56. end
  57.  
  58.  
  59. --------------------------------------------------
  60. -- Нажатие кнопки
  61. --------------------------------------------------
  62.  
  63. confirmButton.Activated:Connect(function()
  64. submitName()
  65. end)
  66.  
  67.  
  68. --------------------------------------------------
  69. -- Enter в TextBox
  70. --------------------------------------------------
  71.  
  72. textBox.FocusLost:Connect(function(enterPressed)
  73.  
  74. if enterPressed then
  75. submitName()
  76. end
  77.  
  78. end)
Advertisement
Add Comment
Please, Sign In to add comment