Where is the best place to store the stats?

Where is the best place to store the stats? im not sure which is the best way or best place to store the stats ex. strength dura stamina hunger etc. Most of the ways I have seem is make a script in serverscriptservice and do function when joined to instance a new value to store stat and make its parent is player, is that correct? or I should store it in script or other way?

Best place is in a ModuleScript that can manage your data for you. You can hand replicate any data you want the player to have with RemoteEvents and keep the rest on the server’s side in pure Lua. Most serious and complex projects will want to aim to do this in some way.

The whole leaderstat way with creating values under the Player is an old way of storing stats that has just carried through the years. Some serious projects still use leaderstats as well but purely as a form of display and not as an authoritative source of data.

Check out Leaderboards for more information. Unfortunately it doesn’t point out good/best practice for leaderboards and data and neither do any data articles.

4 Likes

Expanding upon colbert’s great advice, if you are not confident enough to come up with this system yourself you can utilise @Kampfkarren’s DS2 module that employs Bereeza’s method of caching data in your game and only saving at logical points during runtime (such as a player leaving or developer defined autosaves) as opposed to inconsistent and overwhelming harsh saving that many will fall a victim to when learning about DataStores.

This module stores player data within a module just as @colbert2677 has mentioned, and you can use all manner of methods within that module to get and set data. It also has a bunch of great features and considerations under the hood that make it a great way to save data.

Some people have different opinions on how to store and save data but it’s really down to you to decide.

DataStore2:

2 Likes