The best way to store players data?

English isn’t my native language, apologize for mistakes

What is the best way to store player data? In my past project i created Values in player’s folder and used them. How does it affect a perfomance? Should I create a one folder for all players or use a global table (only in scripts)?

2 Likes

It’s really up to you, since there’s not really any “best” way to approach this, but if you only have one script that needs the data then it’s probably best to go with variables rather than value objects.

It shouldn’t affect performance badly enough to be a big issue either way.

2 Likes

One word, ModuleScripts!

A single module holding all of the the data works perfectly, you can store all of the data within a table and then receive it from the client with ease.

2 Likes

I personally use a physical value data structure like this:

image

I have ran into zero performance issues with this, and it makes client updating extremely simple.

You could definitely store data in a simple table on the server, and pass values to the client as they update. I imagine the difference in performance would be negligible.

7 Likes

I store player data like this except I create a folder in ServerStorage for the player’s data.

The ValueObjects are put on the server this way so there is no risk of a player editing anything locally or viewing values they shouldn’t.

If I want something replicated to the client, I have a separate Folder stored in the Player that updates when the server-side value is updated. (All server-side scripts use the server-sided values).

Whether or not this is efficient I have no idea, but I haven’t run into problems this way.

There’s no risk when a player edits a value locally, those edited values won’t replicate to the server, ever.

As for viewing values, what kind of values are you storing that need to be kept secret?

Your method seems fine too, just sounds like a few extra redundant steps.

I actually use the exact same method as you do for player data. I created a topic about this a few months ago, link here, but according to the responses I got, it should be safe to store it in values in the player. If you’re asking about efficiency, for most data storage, I don’t think that should be a huge issues, unless you create some over the top system that destroys performance.

3 Likes

I highly recommend you to use folders, moreover, using tables can cause problems for example that other players use the data of another player, because tables can be indexed incorrectly.

Redundancy is my specialty

As for values I’m storing that should be private from the clients - I have a sort of password system in which players have to gues a randomly generated password that is player specific. Obviously I wouldn’t store it where the player can see it.

1 Like

Yes, i do this too, but say you’re reading a value on local player, if the value isn’t updated from server, it’ll stay that way for the client, so if client checks it, they can bypass whatever you’ve set up on their own. What i mean is say you have a bool value for game state (intermission, game etc.) And you’re relying on that value for controlling let’s say… sprinting or something… they can change it locally and mess up the local script into thinking it’s what it’s supposed to be.
But for server-server values it works very well…

That’s why you implement server-side checks? You can easily set up guards against unintended behaviours that players enact based on what values the server is watching, not the client. Intermission is on and players aren’t supposed to sprint? Flag them based on their velocity and HumanoidStateType, for example.

1 Like

Yeah… i just send a remote event from server with the info needed. I don’t even bother using values locally.