Issues with players list

Hi devs! I currently making a game where it shows players list on a part. But I ran into this problem. Could you guys tell me what is the problem with the script?

  1. What do you want to achieve? Keep it simple and clear!
    I want to know that whats the issue of the script

  2. What is the issue? Include screenshots / videos if possible!
    Players list not working on surface GUIs

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I looked for it in the dev hub but it didnt help me much

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

Code for surfacegui:

function temp(plrname)
	local clone = script.Parent.ScrollingFrame.Playername:Clone()
	clone.Text = plrname
	clone.Name = plrname
	clone.Parent = script.Parent.ScrollingFrame
	clone.Visible = true
end
game.ReplicatedStorage.AddPlayer.OnClientEvent:Connect(function(plrname)
	temp(plrname)
end)

Code for serverscriptservice:

game.Players.PlayerAdded:Connect(function(plr)
	game.ReplicatedStorage.AddPlayer:FireAllClients(plr.Name)
	game.ReplicatedStorage.CurrentPlayers.Value += 1
end)
game.Players.PlayerRemoving:Connect(function(plr)
	game.ReplicatedStorage.RemovePlayer:FireAllClients(plr.Name)
	game.ReplicatedStorage.CurrentPlayers.Value -= 1
end)


Screenshot 2022-03-16 115143

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

Is Playername something that is inside the scrolling frame? or Playername is supposed to be the new player’s name

Make sure the local script is under one of the following services:
startercharacterscripts
starterplayerscripts
playergui
backpack

You haven’t actually explained the issue.

Uhh So. I was making a game where all players name show on a part. Using A Surfacegui.

playername is a new Player’s Name

The issue is that the all the players name wont show up on the part.

But How will I put it on part?

What? mySG = game.workspace.part.SurfaceGui

Your were making a mistake which is, the Playername isnt on ScrollingFrame, so it should be

script.Parent:Clone() instead of script.Parent.ScrollingFrame.Playername:Clone()

Im not really understanding what you want to do

I’m assuming you want to add the players name to the list when they join the game like the default playerlist.

If I’m correct you could just put a normal script in ServerScriptService (or anywhere else on the server), and use Player.PlayerAdded:connect()/Player.PlayerRemoving:connect() to know when to add/remove the Players username to/from the list. Then you could simply put the Playername textlabel in the script, and clone it into the list by doing something like

local ListReference = game.Workspace:WaitForChild("PlayerList")
local PlayerNameText = Playername:Clone()
PlayerNameText.Parent = ListReference.SurfaceGui.ScrollingFrame

I hope I understood you correctly, and that this helps at least a little.