ObjectValues or Attributes for Player Data

Hey guys, I know this is a personal preference question, but may I know which is better to store Player Data (Example : Kill and Death) (without DataStore), is it better to use ObjectValues like IntValue etc or using attributes? Thank you.

Probably best and most efficient to store this in a table on the server instead of those options. If you ever need to do something with the data as the player leaves or a few seconds after, you can. If you store anything under the player and they leave, it gets destroyed.

I don’t intend to save the data, that’s why I asked about this two. Which one do you think is better? And why I asked about this two, not table, because I think I need remote event for replicating table.

Attributes. They are simply faster.

2 Likes

I know you don’t intend to save the data, but if you were to ever use the data after the player leaves, or if you choose to save data one day, you’d be better off creating a flexible system like a table inside of a script instead of storing anything under the Player instance.

Choosing between ObjectValue and Attributes, I think I’d choose attributes. They look cleaner in the Explorer and are relatively easy to use. Better than calling Instance.new(“ObjectValue”) and setting its parent, etc over just calling SetAttribue.

Both of them can be change by client but if the value’s changed by the client only that client can see see the changed right?

Yeah if it’s not changed by the server, it can’t be seen by others. Don’t trust the client.

I love attributes, as they are easier than object values, however, they can only contain certain value types.

So it really depends on what you want to do.
If its just to keep track of score or kills or deaths, etc…
Attributes are the way to go.

Why not use both? You can use IntValue for the Kill stat, and set an attribute named “Deaths” on it. This might be better because you are utilizing a single class object, and it is efficient.

Emmm?? Can you explain it to me why separate both thing?

Don’t use both, that makes no sense, sorry to @Jozeni00 , but why have two different ways to do something, when one way will work for both.

Consistency is best, and using the best tool for the need should be the solution.

Can you tell me why? Then what should I use then…

If you are just using it to store numbers, use Attributes… here is why
You don’t need to create them as an instance, with .new
If you try to read one, and it has not been created, it won’t error, but just return nil

So they are simple and safe, and work well for storing numbers. You can even check for changes with them.

1 Like

Yup, thanks. I’m using attributes now.

I was slightly confused here, but I see what you mean. You are trying to set attributes on the Player instance instead of creating a new object with an attribute because it takes more time. I agree that setting attributes on the Player for Kills/Deaths is better than what I thought, good thinking!

1 Like

Attributes support Vector3.


Another option is looking into MemoryStore. This method is faster than DataStore and it’s easier to use.

However, if you’re doing “Kill and Death”, then you should use the leaderstats folder, which uses IntValues. This will create a nice leaderboard on your player list as well.

Please mark one of these fine gentleman’s posts as a solution if your question has been answered/addressed to your satisfaction.

Well I have custom player list, so I think I don’t need to use leaderstats?

1 Like

Thanks for the correction, I edited my post