Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Need help with an error?

Asked by 10 years ago

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)

1 answer

Log in to vote
2
Answered by
Azenix 1
10 years ago

you forgot to add an = sign if you wanted the value to change to "New"
so you should replace it with this. you should always check for simple errors like this before posting to this site, as a load of errors are caused by simple typing errors

rnk.Value = "New"
0
You might know i'm famous for little mistakes if you have seen my other questions lol. Operation_Meme 890 — 10y
0
Not famous, but well I have lots of them :3 Operation_Meme 890 — 10y
Ad

Answer this question