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)
PlayerAdded
is server-side only (it's only useful on the server side), and the player joins before the script runs, and when it does, it waits for the NEXT player to join, and it would run code on them. A fix to your script would be to use LocalPlayer
instead.local plr = game:GetService("Players").LocalPlayer 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 = playername frame.PlayerName.PlayerName.Text = playername frame.Rank.Rank.Text = playerfolder[plr.Name].Rank.Value gam.Workspace.Players[plr.Name].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, 255/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/255, 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