I'm following up with this tutorial: https://www.youtube.com/watch?v=rWbQ0x-Xjj4
and I'm typing exactly what the guy is typing. I know it's outdated. This worked a month ago.
Here's my code
game.Players.PlayerAdded:connect(function(player) statistics = Instance.new("IntValue", player) stats.name = "leaderstats" points = Instance.new("IntValue", stats) points.name = "Points" end)
You shouldn't be using stats
as your variable, you defined it as statistics
. Also define them as local variables with the local
keyword.
Also, statistics shouldn't be an IntValue
. It's 2016; we have Folders for a reason!
Global variables should be avoided as much as possible. They aren't "Deprecated", but it is considered bad practice. Firstly because it clutters up the global environment, but also because in Lua, getting or setting a global variable's value is slower than with a local variable.
Also, while unrelated to the question, as RemasteredBox noted, you declared your variable as statistics
but you later refer to it as stats
. This is a mistake.