Very buggy
I'm not sure if you intentionally did this, but your script is littered with errors.
1
You made a typo. Positon
2
Trying to set the text to a player object textButton.Text = p
3
Everytime someone joins, it creates a new text button with the name of the player looking at it. So if I tested it in multiplayer, it would be 'Player1, Player1' and for the other player, 'Player2, Player2' textButton.Text = p.Name
4
You have a very dodgy position there. That is way off the SCREEN! Also, you will need to see which llines are taken and that, etc.
5
Unreadable text. Your background transparency is a bit off. 0.9
makes the white text almost unreadable. I set it to 0.1
because that looks better.
The event
This is where the main issue is. Your PlayerAdded event is not firing. I tried putting it in Workspace
and then just tweaked the code, and it worked fine.
Fixed code
01 | local Players = game:GetService( "Players" ) |
03 | game:GetService( "Players" ).PlayerAdded:connect( function (Player) |
04 | for _,p in pairs (Players:GetPlayers()) do |
05 | local textButton = Instance.new( "TextButton" ,p.PlayerGui:WaitForChild( "PlayerList" ).ScrollingFrame) |
06 | textButton.BackgroundColor 3 = BrickColor.Black().Color |
07 | textButton.BackgroundTransparency = 0.1 |
08 | textButton.BorderColor 3 = BrickColor.White().Color |
09 | textButton.Position = UDim 2. new( 0 , 0 , 0 , 0 ) |
10 | textButton.Size = UDim 2. new( 0 , 200 , 0 , 25 ) |
11 | textButton.Font = Enum.Font.ArialBold |
12 | textButton.FontSize = Enum.FontSize.Size 18 |
13 | textButton.Text = Player.Name |
14 | textButton.TextColor 3 = BrickColor.White().Color |
15 | textButton.Archivable = true |
Thanks for reading!
Thanks for reading my answer. I hope it helped you. If it did, don't forget to upvote it or set it as the correct answer!