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

How to get all players to show up in a gui?

Asked by
Runsta 0
6 years ago

Hello I'm trying to figure out how to get all players connected on a server too show up in a custom made gui?

Like for example. A drop down menu. You click that shows a list of all the players currently online and you can select one. Then everything else you select in the gui is for that player you selected only.

So lets say I make me a custom admin gui for my server.

In that gui I got all kinds of commands.

I click my dropdown menu in my custom made gui select "DonaldBuck" whos currently online and connected to the server then click a button called 'God mode' and it makes only him have god mode in the server

thanks

0
An easy solution is to have a for loop go through all of the children of Players and put them into textbuttons RockerCaleb1234 282 — 6y

1 answer

Log in to vote
0
Answered by
2eggnog 981 Moderation Voter
6 years ago

Using a for loop, loop through the players and add each one to the list. Here's some sample code.

local list --Your container for your list of players
local sampleLabel = dropDownMenu.SampleLabel --An invisible sample label at the top
for i, player in ipairs(game.Players:GetPlayers()) do
    local label sampleLabel:Clone()
    label.Text = player.Name
    label.Position = sampleLabel.Position + UDim2.new(0, 0, sampleLabel.Size.Y.Scale* (i - 1), sampleLabel.Size.Y.Offset * (i - 1) ) --Position the label based on the player index
    label.Visible = true
    label.Parent = list
end
Ad

Answer this question