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

How do I get a list of all the player's in the server on a ScrollingFrame?

Asked by 6 years ago
Edited 6 years ago

I want to get the list of all players that are in the game in a ScrollingFrame in a ScreenGui, how would I go about doing this? The "templateBtn" is the button that contains the player's name.

https://gyazo.com/75bdbdefcd0dddadd3d8d7522eed7bee

0
I would awnser,but i dont know how to post you the code. is it inline code or code block User#20192 0 — 6y
0
You just take the code as you see it in a script, copy it, and paste it in the "Answer this question" box. Then you select it all and click the "Lua" button to the right of the "C". Char187 0 — 6y

2 answers

Log in to vote
0
Answered by 6 years ago
--// GetService is a handy tool that returns the service no matter what (in case the service is renamed etc)
local SG = game:GetService("StarterGui")
local Players = game:GetService("Players")

local GUI = SG.fnrGui.servingFrame.playerlist --// Assuming from the screenshot
local Btn = GUI.templateBtn:Clone()
GUI.templateBtn:Destroy() --// The Instance is not needed anymore

Players.PlayerAdded:Connect(function(player) --// When a player joins the game it fires the function.
    local Btn = Btn:Clone()
    Btn.Text = player.Name
    Btn.Parent = GUI
end)

for _,player in pairs(Players:GetPlayers()) do --// Needed when testing in solo mode.
    local Btn = Btn:Clone()
    Btn.Text = player.Name
    Btn.Parent = GUI
end

This script makes a clone of your templateBtn and destroys the original. Once a new player joins the game and if there is any players it makes new templateBtns and changes the Text property to their name. Also I'm assuming from the screenshot that you don't need to position the new part because of the UIGridLayout Instance.

Hope this helps.

0
Thanks! It works c: ShiforRBLX 5 — 6y
0
No problem. DaYoIoMan 30 — 6y
Ad
Log in to vote
-1
Answered by 6 years ago
p=game.StarterGui.ScreenGui.ScrollingFrame--repplace  this with location of your scrolling  frame that you want the players to be on
game.Players.PlayerAdded:connect(function()--when a player joins the game it fires this event
g=+1
b=Instance.new("TextButton",p)--makes a new text button when a player joins
b.Text=game.Players.LocalPlayer.PlayerName--makes the text the player's name
b.Position=g*60--makes the text button position (down) increase 60 each time a player joins,since each time a player join,g is increased by 1
end)--ends the event

when a player joins a new textbox is created for a players name.And the position goes down by 60 for each time.Friend me im danielp533 im a great scripter and happy to help.Tell me if it dont work

0
There's an error on line 3 where the + is ShiforRBLX 5 — 6y
0
The script also wouldn't properly position a frame since all GUIs require a UDim2.new() function. I'll see what I can do, Shi. TheRings0fSaturn 28 — 6y
0
dude i just gave you the basics turn +1 to 0+1 and finish the instancing statememt User#20192 0 — 6y

Answer this question