Advertisement
TrapeZ_Dev

ai test

Jun 11th, 2025
1,144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.21 KB | None | 0 0
  1. local Players = game:GetService("Players")
  2. local ScreenGui = Instance.new("ScreenGui")
  3. ScreenGui.Name = "PlayerListScreen"
  4. ScreenGui.Parent = game.Players.LocalPlayer:WaitForChild("PlayerGui")
  5.  
  6. local PlayerListFrame = Instance.new("Frame")
  7. PlayerListFrame.Name = "PlayerListFrame"
  8. PlayerListFrame.Size = UDim2.new(0.8, 0, 0, 0)
  9. PlayerListFrame.Position = UDim2.new(0.1, 0, 0, 0)
  10. PlayerListFrame.BackgroundColor3 = Color3.new(0.2, 0.2, 0.2) -- Dark grey background
  11. PlayerListFrame.BorderSizePixel = 0
  12. PlayerListFrame.Parent = ScreenGui
  13.  
  14. local PlayerListTextBox = Instance.new("TextBox")
  15. PlayerListTextBox.Size = UDim2.new(1, 0, 0, 0)
  16. PlayerListTextBox.SizeConstraints = UDim2.new(1, 0, 0, 0)
  17. PlayerListTextBox.Multiline = true
  18. PlayerListTextBox.BackgroundColor3 = Color3.new(0.3, 0.3, 0.3) -- Slightly lighter background
  19. PlayerListTextBox.BorderSizePixel = 0
  20. PlayerListTextBox.Parent = PlayerListFrame
  21.  
  22. -- Function to update the player list
  23. local function UpdatePlayerList()
  24.     local playerList = ""
  25.     for i, player in pairs(Players:GetPlayers()) do
  26.         local playerName = player.Name
  27.         local playerGui = player.PlayerGui
  28.         if playerGui then
  29.             local playerListButton = playerListButton
  30.             playerListButton.BackgroundColor3 = Color3.new(1, 1, 1) -- Highlight when hovered
  31.             local playerListButton = Instance.new("TextButton")
  32.             playerListButton.Size = UDim2.new(0.8, 0, 0, 0)
  33.             playerListButton.Position = UDim2.new(0.1, 0, 0, 0)
  34.             playerListButton.BackgroundColor3 = Color3.new(0.3, 0.3, 0.3)
  35.             playerListButton.BorderSizePixel = 0
  36.             playerListButton.Text = playerName
  37.             playerListButton.Parent = PlayerListFrame
  38.             playerListButton.Size = UDim2.new(0.8, 0, 0, 0)
  39.             playerListButton.Position = UDim2.new(0.1, 0, 0, 0)
  40.             playerListButton.BorderSizePixel = 0
  41.             playerListButton.Text = playerName
  42.             playerListButton.Parent = PlayerListFrame
  43.             playerListButton.Size = UDim2.new(0.8, 0, 0, 0)
  44.             playerListButton.Position = UDim2.new(0.1, 0, 0, 0)
  45.             playerListButton.BorderSizePixel = 0
  46.             playerListButton.Text = playerName
  47.             playerListButton.Parent = PlayerListFrame
  48.  
  49.             if playerList == "" then
  50.                 playerList = playerName
  51.             else
  52.                 playerList = playerList .. ", " .. playerName
  53.             }
  54.         end
  55.     end
  56.  
  57.     PlayerListTextBox.BackgroundColor3 = Color3.new(0.3, 0.3, 0.3)
  58.     PlayerListTextBox.Text = "Players: " .. playerList
  59.  
  60.     -- Clean up the buttons to prevent memory leaks
  61.     for i, button in pairs(PlayerListFrame.Children) do
  62.         if button:IsA("TextButton") then
  63.             button:Destroy()
  64.         end
  65.     end
  66. end
  67.  
  68. -- Call the function to update the list initially
  69. UpdatePlayerList()
  70.  
  71. -- Event listener for when the player clicks on a button
  72. PlayerListFrame.UserAdded:Connect(function(player)
  73.     -- Update the list when a player joins
  74.     UpdatePlayerList()
  75. end)
  76.  
  77. -- Event listener for when the player leaves the server
  78. Players.PlayerDropped:Connect(function(player)
  79.     -- Update the list when a player leaves
  80.     UpdatePlayerList()
  81. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement