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
--// 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.
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