Hey. I'm currently working on a PlayerList with all the names of all players in the game. I want to display them on a part but something isn't working. It works fine with a ScreenGUI but I must display it on a SurfaceGUI and that's the problem. It's not showing up on the SurfaceGUI and I don't know why.
local BoardList = game:GetService("ReplicatedStorage"):WaitForChild("BoardList") local holder = script.Parent:WaitForChild("holder") local function add(player) local new = BoardList:Clone() new.name.Text = player.Name if not new.name.TextFits then new.name.TextScaled = true end new.Position = UDim2.new(0, 190, 0 + (.103 * #holder:GetChildren()), 0) new.Parent = holder end add(game.Players.LocalPlayer) game.Players.PlayerAdded:Connect(function(player) add(player) end)
Alright. I tested out your code, and it seems to be working good.
Although, I did remove the repositioning line since it did not really work. In exchange I placed an UIListLayout inside the SurfaceGui to make prevent the GuiObjects from overlapping. You can see how i did it inside this place: (It is uncopylocked) https://www.roblox.com/games/4709982824/Scriptinghelpers
I did also remove the add(game.Players.LocalPlayer) since the script is a serverscript and can't call a localPlayer.
local BoardList = game:GetService("ReplicatedStorage"):WaitForChild("BoardList") local holder = script.Parent:WaitForChild("holder") local function add(player) local new = BoardList:Clone() new.name.Text = player.Name if not new.name.TextFits then new.name.TextScaled = true end new.Parent = holder end game.Players.PlayerAdded:Connect(function(player) add(player) end)
And that's about it. Feel free to comment if there was something I didn't answer correctly or you have more question.
Happy scripting!
~Sethex