My Leaderboard script displays a leaderboard for every player in the game, except the first player that joins. How can I fix this?
function playerAdded(plr) local stats = Instance.new("IntValue", plr) stats.Name = "leaderstats" local KOs = Instance.new("IntValue", stats) KOs.Name = "Kills" KOs.Value = 0 local WOs = Instance.new("IntValue", stats) WOs.Name = "Deaths" WOs.Value = 0 local Money = Instance.new("IntValue", stats) Money.Name = "Bronze" Money.Value = 0 local XP = Instance.new("IntValue", stats) XP.Name = "XP" XP.Value = 0 end game.Players.PlayerAdded:connect(playerAdded)
It might have been declared before the player could actually join. Try adding this line to make sure that your character is in the game. repeat wait() until plr.Character
function playerAdded(plr) repeat wait() until plr.Character local stats = Instance.new("IntValue", plr) stats.Name = "leaderstats" local KOs = Instance.new("IntValue", stats) KOs.Name = "Kills" KOs.Value = 0 local WOs = Instance.new("IntValue", stats) WOs.Name = "Deaths" WOs.Value = 0 local Money = Instance.new("IntValue", stats) Money.Name = "Bronze" Money.Value = 0 local XP = Instance.new("IntValue", stats) XP.Name = "XP" XP.Value = 0 end game.Players.PlayerAdded:connect(playerAdded)