Advertisement
coneman_2737

Texto a jugadores

Aug 1st, 2024
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.11 KB | None | 0 0
  1. -- Local Script
  2.  
  3. -- Variables
  4. local Players = game:GetService("Players")
  5. local Player = Players.LocalPlayer
  6. local Gui = Instance.new("ScreenGui", Player.PlayerGui)
  7. local PlayerListFrame = Instance.new("Frame", Gui)
  8. local MessageTextBox = Instance.new("TextBox", PlayerListFrame)
  9. local SendMessageButton = Instance.new("TextButton", PlayerListFrame)
  10.  
  11. -- UI Properties
  12. Gui.Name = "MessageGui"
  13. PlayerListFrame.Size = UDim2.new(0.3, 0, 0.5, 0)
  14. PlayerListFrame.Position = UDim2.new(0.35, 0, 0.25, 0)
  15. PlayerListFrame.BackgroundTransparency = 0.3
  16.  
  17. MessageTextBox.Size = UDim2.new(0.8, 0, 0.1, 0)
  18. MessageTextBox.Position = UDim2.new(0.1, 0, 0.8, 0)
  19. MessageTextBox.PlaceholderText = "Enter message (max 20 chars)"
  20. MessageTextBox.Text = ""
  21.  
  22. SendMessageButton.Size = UDim2.new(0.8, 0, 0.1, 0)
  23. SendMessageButton.Position = UDim2.new(0.1, 0, 0.9, 0)
  24. SendMessageButton.Text = "Send Message"
  25.  
  26. -- Create a list of players
  27. local function updatePlayerList()
  28. for _, v in pairs(PlayerListFrame:GetChildren()) do
  29. if v:IsA("TextButton") and v ~= SendMessageButton then
  30. v:Destroy()
  31. end
  32. end
  33.  
  34. local yPosition = 0
  35. for _, player in pairs(Players:GetPlayers()) do
  36. if player ~= Player then
  37. local PlayerButton = Instance.new("TextButton", PlayerListFrame)
  38. PlayerButton.Size = UDim2.new(0.8, 0, 0.1, 0)
  39. PlayerButton.Position = UDim2.new(0.1, 0, yPosition, 0)
  40. PlayerButton.Text = player.Name
  41. PlayerButton.MouseButton1Click:Connect(function()
  42. sendMessage(player)
  43. end)
  44. yPosition = yPosition + 0.1
  45. end
  46. end
  47. end
  48.  
  49. -- Function to send message
  50. local function sendMessage(targetPlayer)
  51. if #MessageTextBox.Text <= 20 and #MessageTextBox.Text > 0 then
  52. local MessageGui = Instance.new("ScreenGui", targetPlayer.PlayerGui)
  53. local MessageLabel = Instance.new("TextLabel", MessageGui)
  54.  
  55. MessageGui.Name = "PopupMessage"
  56. MessageLabel.Size = UDim2.new(0.8, 0, 0.1, 0)
  57. MessageLabel.Position = UDim2.new(0.1, 0, 0.45, 0)
  58. MessageLabel.Text = MessageTextBox.Text
  59. MessageLabel.TextScaled = true
  60. MessageLabel.BackgroundTransparency = 0.5
  61.  
  62. wait(50)
  63. MessageGui:Destroy()
  64. end
  65. end
  66.  
  67. -- Events
  68. SendMessageButton.MouseButton1Click:Connect(function()
  69. if MessageTextBox.Text and #MessageTextBox.Text <= 20 then
  70. for _, playerButton in pairs(PlayerListFrame:GetChildren()) do
  71. if playerButton:IsA("TextButton") and playerButton ~= SendMessageButton then
  72. playerButton.MouseButton1Click:Connect(function()
  73. local targetPlayer = Players:FindFirstChild(playerButton.Text)
  74. if targetPlayer then
  75. sendMessage(targetPlayer)
  76. end
  77. end)
  78. end
  79. end
  80. else
  81. warn("Message must be 20 characters or less!")
  82. end
  83. end)
  84.  
  85. Players.PlayerAdded:Connect(updatePlayerList)
  86. Players.PlayerRemoving:Connect(updatePlayerList)
  87.  
  88. -- Initialize player list
  89. updatePlayerList()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement