Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Player List Menu, but nothing shows on the GUI when tested?

Asked by
waifuSZN 123
7 years ago
local Players = game:GetService("Players")
Players.PlayerAdded:connect(function(Player)
    for _,p in next, Players:GetPlayers() do
        script.Parent.ScrollingFrame:ClearAllChildren()
        local textButton = Instance.new("TextButton",script.Parent.ScrollingFrame)
        textButton.BackgroundColor3 = BrickColor.Black().Color
        textButton.BackgroundTransparency = 0.9
        textButton.BorderColor3 = BrickColor.White().Color
        textButton.Positon = UDim2.new(2, 0, 1, 0)
        textButton.Size = UDim2.new(0, 200, 0, 25)
        textButton.Font = Enum.Font.ArialBold
        textButton.FontSize = Enum.FontSize.Size18
        textButton.Text = p
        textButton.TextColor3 = BrickColor.White().Color
        textButton.Archivable = true
    end
end)

When run, a textbutton should appear with the players name on it.

Nothing shows up.

Please help.

Please no Remote Events.

1 answer

Log in to vote
1
Answered by
xAtom_ik 574 Moderation Voter
7 years ago

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

local Players = game:GetService("Players")

game:GetService("Players").PlayerAdded:connect(function(Player)
    for _,p in pairs(Players:GetPlayers()) do
        local textButton = Instance.new("TextButton",p.PlayerGui:WaitForChild("PlayerList").ScrollingFrame) -- Replace PlayerList with the name of your gui.
        textButton.BackgroundColor3 = BrickColor.Black().Color
        textButton.BackgroundTransparency = 0.1
        textButton.BorderColor3 = BrickColor.White().Color
        textButton.Position = UDim2.new(0, 0, 0, 0)
        textButton.Size = UDim2.new(0, 200, 0, 25)
        textButton.Font = Enum.Font.ArialBold
        textButton.FontSize = Enum.FontSize.Size18
        textButton.Text = Player.Name
        textButton.TextColor3 = BrickColor.White().Color
        textButton.Archivable = true
    end
end)

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!

0
Think answer helped me alot in getting the right method. thanks. waifuSZN 123 — 7y
0
Always remember to double check your code. xAtom_ik 574 — 7y
Ad

Answer this question