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

Global Stats Is Deprecated?

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)

2 answers

✓ Accepted answer

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!

4 comments

1

Hey, I didn't know leaderstats could be anything but IntValue. I had to test this real quick. That's good to know. Have an upvote.

0

Link's such a loser.

0

Thanks!

0

Thanks guys! And if you have any more questions just ask OP! (Or link lol)

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.

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