So I recently followed a tutorial to experience with making a custom player list gui, but it doesn’t seem to work, I don’t really remember from who I took the tutorial I am sorry for that but here is the code.
game:GetService("StarterGui"):SetCoreGuiEnabled(Enum.CoreGuiType.PlayerList, false)
local Item = game.ReplicatedStorage:WaitForChild("Item")
local Holder = script.Parent:WaitForChild("Holder")
local function add(Player)
local New = Item:Clone()
New.Name = Player.Name
New.Name.Text = Player.Name
if not New.Name.TextFits then
New.Name.TextScaled = true
end
New.Position = UDim2.new(.87, 0, .01 + (.05 * #Holder:GetChildren()), 0)
New.Parent = Holder
end
for i,v in pairs(game.Players:GetPlayers()) do
add(v)
end
game.Players.PlayerAdded:Connect(function(Player)
add(Player)
end)
game.Players.PlayerRemoving:connect(function(Player)
local find = Holder:FindFirstChild(Player.Name)
if find then
find:Destroy()
for i,v in pairs(game.Players:GetPlayers()) do
v.Position = UDim2.new(.87, 0, .01 + (.05 * #Holder:GetChildren()), 0)
end
end
end)
The issue here is you have a TextLabel named Name. Class members (properties, events, methods) have higher precedence over children, so you’re getting the Name property and not a child.
So rename it to something like PlayerName and it will work.
Okay so I have changed the name of the TextLabel inside the Frame but it still says a error in the output, here are the changed code, workspace and the error and thanks for pointing out one of the problems!
Code:
game:GetService("StarterGui"):SetCoreGuiEnabled(Enum.CoreGuiType.PlayerList, false)
local Item = game.ReplicatedStorage:WaitForChild("Item")
local Holder = script.Parent:WaitForChild("Holder")
local function add(Player)
local New = Item:Clone()
New.pName = Player.Name
New.pName.Text = Player.Name
if not New.pName.TextFits then
New.pName.TextScaled = true
end
New.Position = UDim2.new(.87, 0, .01 + (.05 * #Holder:GetChildren()), 0)
New.Parent = Holder
end
for i,v in pairs(game.Players:GetPlayers()) do
add(v)
end
game.Players.PlayerAdded:Connect(function(Player)
add(Player)
end)
game.Players.PlayerRemoving:connect(function(Player)
local find = Holder:FindFirstChild(Player.Name)
if find then
find:Destroy()
for i,v in pairs(game.Players:GetPlayers()) do
v.Position = UDim2.new(.87, 0, .01 + (.05 * #Holder:GetChildren()), 0)
end
end
end)