I made this leaderstats script in workspace. I did exactly the same thing on what the tutorial said. But it says I have an error on line 14 saying: Attempt to call a field 'Value' (A string value) Here's the script:
lvlkey = "lv"
rankkey = "rnk"
game.Players.PlayerAdded:connect(function(player)
local l = Instance.new("IntValue")
l.Name = "leaderstats"
local lv = Instance.new("IntValue", l)
lv.Name = "Lvl"
lv.Value = 1
local rnk = Instance.new("StringValue", l)
rnk.Name = "Rank"
rnk.Value "New" -- Error --
-- Loading --
player:WaitForDataReady()
lv.Value = player:LoadNumber(lvlkey)
rnk.Value = player:LoadString(rankkey)
end)
-- Auto saving --
game.Players.PlayerRemoving:connect(function(player)
player:SaveNumber(lvlkey, player.leaderstats.Lvl.Value)
player:SaveString(rankkey, player.leaderstats.Rank.Value)
end)

2 comments
You might know i'm famous for little mistakes if you have seen my other questions lol.
Not famous, but well I have lots of them :3