Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Need help with an error?

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

✓ Accepted answer

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"

2 comments

0

You might know i'm famous for little mistakes if you have seen my other questions lol.

0

Not famous, but well I have lots of them :3

This discussion is preserved as it was. New answers, comments, and votes are closed.