My leaderstats script doesnt seem to work. I've changed it several times, but no matter what I do, it won't work. If anyone can help me here it is:
local nshow = {"attack","strength","defense","fishing","smithing","fletching","cooking",
"woodcutting","crafting","theiving","prayer","farming"} --Different non-showing skills
--Load Data
game.Players.PlayerAdded:connect(function(player)
player:WaitForDataReady()
--Leaderstats
leaderstats.Parent = game.Players:FindFirstChild(player)
leaderstats.Name = "leaderstats"
Level = Instance.new("IntValue")
Level.Parent = leaderstats
Gold = Instance.new("IntValue")
Gold.Parent = leaderstats
Skill = Instance.new("IntValue")
Skill.Parent = leaderstats
Gold.Name = "Gold"
Level.Name = "Gold"
Skill.Name = "Skill"
if not pcall(function() Skill.Value = player:LoadNumber("Skill") end) then
Skill.Value = 0
end
if not pcall(function() Gold.Value = player:LoadNumber("Gold") end) then
Gold.Value = 0
end
if not pcall(function() Level.Value = player:LoadNumber("Level") end) then
Level.Value = 1
end
--stats
local stats = Instance.new("Configuration", player)
stats.Name = "stats"
for _, stat in pairs(nshow) do
stata = Instance.new("IntConstrainedValue", stats)
stata.Name = stat
stata.MinValue = 1
stata.MaxValue = 99
if not pcall(function() stata.Value = player:LoadNumber(stat.Name) end) then
stata.Value = 0
end
Instance.new("IntValue",stata).Name = "xp"
if not pcall(function() stat.Value = player:LoadNumber(stat.Name.."xp") end) then
stat.Value = 0
end
Instance.new("IntValue",stata).Name = "nxp"
end
end)
--Save Data
game.Players.PlayerRemoving:connect(function(player)
player:WaitForDataReady()
for i,e in pairs(nshow) do
player:SaveNumber(e.Name,player.stats:FindFirstChild(e).Value)
player:SaveNumber(e.Name.."xp",player.stats:FindFirstChild(e).xp.Value)
end
player:SaveNumber("Skill",Skill.Value)
player:SaveNumber("Gold",Gold.Value)
player:SaveNumber("Level",Level.Value)
end)

6 comments
Can you be more specific on what isn't working?
I really can't. I have run it several times but it does not error, and it doesn't give the leaderstats to the player. Sorry I can't give more info.
Are you only testing this in play solo? In solo, the player is made before playeradded fires.
Perhaps through some print lines here and there, to see how far it goes until it crashes?
I am testing in server. I'll try the print thing later. a little busy right now...
You never defined "leaderstats"