How to use DataStore2 - Data Store caching and data loss prevention

DataStore2 doesn’t save until the player leaves the game. It will be fine.

Don’t worry I got it to fix. I messaged the other scripter and he forgot to add something, so all you would have to do it check if it doesn’t exists then add it to the data store.

I get this error occasionally. Anyone else having this issue?

image
Any idea why this error happens? Ever since I replaced some gets with gettable this happens and I think this throws an error and prevents the rest of the script from running

Does anyone know how I can save attributes in datastore2 ?

If someone has an idea regarding this problem/bug, please reply. It is eating my brains atm.

Could this be used for leaderboards or would you need a seperate data store for that?

use OrderedDataStore Service for LBs

You cant, just litreally save the value in the data store and then in the script get that value and apply it onto the attribute

What is the 100 part, I’m confused on how DataStore:Get() parameters work. If anyone could ELI5 that would be great, thank you.

That’s the default value if none exists in the data store.

2 Likes

Default Value’s most likely 0, or nil

No, what they mean is the input value (100 in this case) is the user-set default value.
Rather than setting the default and then overriding it if there is existing data (as is done with regular datastores), this checks if there is data first and sets the value to whatever your inputted value is in the event of no data

1 Like

I see, I thought they were asking what the manually set data was for, I should’ve looked more into the message before answering, that’s for the correction <3

1 Like

How do I save weapons with this datastore? Thx for replying.

What do you mean by this. Weapons can come in many forms. Do you mean Roblox tools or is it something you created yourself.

Either way, you should save a table with a unique key for that weapon and all its adjustments/attachments/skins, and when you load the dataStore, just load the weapon data and recreate a copy of the same weapon.

I’ve learned many things about this module today, and I’m definitely gonna use this in my games! You did a really good job on this one! :+1: :grin:

Is it possible to change datastores from the client?

Only the server can, you’ll need to validate data sent from the client for security purposes.

1 Like

I’ve made an inventory system that saves data in a string, is there a way to erase data for testing purposes?