Tower of Hell shop saving system

Hey there, so I’m currently working on a shop similar to Tower of Hell’s. However, one problem I can’t get my head around on is how to actually save and load things you’ve bought in the shop.

Would you need a leaderstat for each shop product and set its value to true once bought or use a somewhat more efficient way that I haven’t thought of. I would appreciate any methods you’ve used before or advise, thanks!

4 Likes

Honestly, I’d make a module and store all the items there, containing its name, index, etc. You could save the items using the item’s index, and store that index inside the player’s data. It’s a nice way to save things using a number/index for example instead of its name, that way, it won’t take much data.

3 Likes

No, what you’re going to be doing is something similar to an inventory save system.

The way I’d probably go about it is to have a folder of some sort that gets placed into the StarterPlayerScripts that’s filled with Bool Values that correspond with each item, default set to false. For instance if you wanted a rainbow trail you would have a rainbow trail Bool Value. I would then make a data store which saves any values that are set to true, for instance if the rainbow trail bool were set to true (if you owned it) then that would be saved and loaded back later. Screenshot of what I kind of mean will be below.

If you need clarity on anything or have any suggestions for different methods I’m open to hearing them too! Hope this helps.

2 Likes

This is what I had an idea on on the first post. That however, I would find inefficient as you’ll use lots of BoolValues, potentially decreasing performance if you have hundreds of shop items.

I understand that, personally I like the organization of it all, but I suppose it works just as well with a module script with a table that can be accessed. See if that’d better fit your needs.

But with a module script your data can be cached therefore accessed faster rather than getting an instance. For a large scale inventory system I would much rather use modules than use hundreds of instances.

Create a table on your datastore script (for each player) and use table.insert when a item is bought, you can call SetAsync and GetAsync to fetch / save the table, you can create a dictionary in the script for each player’s data.

If you want to get the items bought on the client, use a remote function and when invoked, handle the callback on your datastore script, get the players data from the dictionary that stores all the players’ data, and return it to the client.

Honestly just use profile service. It’s easier using a module rather than creating you own. It has session locking, cached data and patches glitches.

Hi Phantomize.

Can’t you save tables in DataStores? I think you can do that.
Why isn’t anyone talking about DataStores?

Thats’s what I said…?

It’s still the same method, you store each players data in a dictionary, Profile Service just handles saving / loading data with a slightly more advanced way and session locking, cached data, etc.

The OP is asking how to handle shop purchases, not how to save the data

1 Like

But can you restore corrupted data with that method? No.

Like I said, the OP wants to know how to handle purchases, NOT how to save & load data. Profile Service is a good module, but it’s a bit off-topic here.

how to do “module and store all items there”?