Hasli4

Untitled

Aug 29th, 2026
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. local ReplicatedStorage = game:GetService("ReplicatedStorage")
  2.  
  3. local enterNameEvent = ReplicatedStorage:WaitForChild("EnterName")
  4.  
  5. local dialog = workspace.NPC.Head.Dialog
  6.  
  7. local nameChoice = dialog:WaitForChild("DialogChoice")
  8.  
  9. dialog.DialogChoiceSelected:Connect(function(player, choice)
  10. if choice == nameChoice then
  11. enterNameEvent:FireClient(player)
  12. end
  13. end)
  14.  
  15. enterNameEvent.OnServerEvent:Connect(function(player, playerName)
  16. if typeof(playerName) ~= "string" then
  17. return
  18. end
  19.  
  20. playerName = playerName:match("^%s*(.-)%s*$")
  21.  
  22. if playerName == "" then
  23. return
  24. end
  25.  
  26. -- Ограничиваем длину
  27. playerName = string.sub(playerName, 1, 20)
  28.  
  29. -- Сохраняем имя только для этого игрока
  30. player:SetAttribute("DialogName", playerName)
  31.  
  32. print(player.Name .. " ввёл имя: " .. playerName)
  33. end)
Advertisement
Add Comment
Please, Sign In to add comment