I have a code here which adds a player to my custom made playerlist here.
The PlayerAdded event in this local script does not work, I get no error, nor a print which is part of the code.
game.Players.PlayerAdded:Connect(function(plr)
wait(0.1)
print(plr.Name)
local playername = plr.Name
script.Parent.PlayerTemplate:Clone().Parent = script.Parent.Background
local frame = script.Parent.Background:WaitForChild("PlayerTemplate")
wait()
frame.Name = playername
frame.Visible = true
frame.Name = (plr.Name)
frame.PlayerName.PlayerName.Text = playername
frame.Rank.Rank.Text = playerfolder[plr.Name].Rank.Value
game.Workspace.Players[plr.Name].Team.Changed:connect(function()
local pf = game.Workspace.Players[plr.Name]
print(pf.Team.Value)
if pf.Team.Value == game.Teams.Sierra.Name then
print(plr.Name.." updating leaderboards so this player is in team Sierra")
print(script.Parent.Background[plr.Name].BackgroundColor3)
script.Parent.Background[plr.Name].BackgroundColor3 = Color3.new(0, 170, 255)
elseif pf.Team.Value == game.Teams.Tango.Name then
print(script.Parent.Background[plr.Name].BackgroundColor3)
script.Parent.Background[plr.Name].BackgroundColor3 = Color3.new(170, 0, 0)
print(plr.Name.." updating leaderboards so this player is in team Tango")
else
print(script.Parent.Background[plr.Name].BackgroundColor3)
print(plr.Name.." updating leaderboards so this player is not in team Tango or Sierra")
script.Parent.Background[plr.Name].BackgroundColor3 = Color3.new(0,0,0)
end
end)
if plr:IsInGroup(4023191) then
frame.Capbadge.ImageLabel.Image = ("rbxassetid://1567461093")
elseif plr:IsInGroup(1197643) then
frame.Capbadge.ImageLabel.Image = ("rbxassetid://117739276")
elseif plr:IsInGroup(1197645) then
frame.Capbadge.ImageLabel.Image = ("rbxassetid://239367802")
elseif plr:IsInGroup(4030193) then
frame.Capbadge.ImageLabel.Image = ("rbxassetid://756770459")
elseif plr:IsInGroup(4023094) then
frame.Capbadge.ImageLabel.Image = ("rbxassetid://193965796")
elseif plr:IsInGroup(3773876) then
frame.Capbadge.ImageLabel.Image = ("rbxassetid://702638350")
end
end)

4 comments
When I add a break in my code it shows plr.Name as a value not found.
Does the script fire the "print(plr.Name)" on line 3?
Not sure, but I think it might. But nothing is printed in the console, but when I add a break in my code and hover over "plr.Name" it shows plr.Name as a value not found.
Are you testing this in a Roblox Studio single player test? Because PlayerAdded doesn't fire if you do that.