Saving a folder with objectvalues to a datastore?

What the title says. I’m trying to use ForeverHD’s Crate spin system Creating a Crate/Spin System, and I’m trying to make the stuff save. I already got the cash and the amount of items unlocked to save, the only thing left is the “Inventory” folder that has +1 objectvalue every time you unlock a new character/item. How can I make it save?

I’ve followed ALL tutorials on the internet; DevForum, Google, YouTube, everything. Nothing worked. That’s why I’m asking here

Any help appreciated!

Its better to use string values, and use a couple of them, holding all the properties / things needed for the item, i dont think its possible to save object values (it could be so try)

1 Like

What @msix29 said, use serialization.

That’s the thing, the object values used in the spin crate system don’t have any actual values to them. It’s just an object value with a name, and nothing else, parented to one folder; there are no properties I need to save, I just need the actual instances to stay in the folder inside the player when the player rejoins

Why save as object values then, they have no value so loop through them, add their NAMES to a table and save it, when loading, loop through the table you saved, for every item create an object value with that name

Hi, I have a small script for this;

image

by the way, yes, I know the error is that UpdateAsync isn’t set up properly, but I just saw a post explaining that I should use UpdateAsync instead of SetAsync because SetAsync can cause data loss so I just replaced SetAsync to UpdateAsync, but I don’t really understand how to properly use UpdateAsync so can you help me a bit with it please=

You should use a pcall and make sure it succeed, you can use Datastore2 as a better alternative to normal Datastore

1 Like

I’m not very experienced with scripting though, and DataStore2 seems too complicated for me and I don’t understand what to do with pcall, + I already use another saving module which is easy BUT doesn’t support tables/what I’m trying to do so adding another module like DataStore2 kinda seems pointless for my situation since having 2 ds modules wouldn’t be very practical ig

What I mostly don’t understand is what to put in the “oldData” thing that’s in every single UpdateAsync sample script; do I just put the table? Wouldn’t that be the new data though??

Place old data as yourStore:GetAsync(key) or {}, this will most probably fix your problems, itd what the data looked like when the player joined…

Alright, ima try that after I’m done making some characters I was just making and I’ll let u know if it works

1 Like