Tracking how many of an item exists

So, I have this game where I want to add trading, but an issue is, values can’t be properly calculated without a ‘true’ “how many of this exists” counter. I know this is done with external databases, but how would I do that? Would I need my data to not only be stored on the game itself, but also on an external database? I don’t want to make it only start counting instances now, because the values wouldn’t be accurate since the game has already gained some playerbase.

It seems to me that you’re looking for DataStores.

Isn’t this article on in-game datastoring? I already have a datastore script working. I want to learn on how to store data EXTERNALLY. Not on roblox.

But that’s unnecessary. You don’t need an external database. You can just use a DataStore for this as well. Then you would update it’s value every time an item is added.

For less latency issues, you can also only update the datastore every couple minutes and when the server shuts down. Then you just need to keep a table in a server script which you use as a buffer.

Why do you need this to be externally anyway?
Http request are rate limited as well, which could cause issues later down the line.

I was just thinking since, a lot of people have already played, they would probably already have a lot of items, and if they never actually JOINED after the tracking update, it wouldn’t count their items so. But I guess I’ll try that if that’s the only solution.

Well I’m not sure but I assume you saved how many items each player has in the DataStore you already implemented? If so you can probably just read through all the data in there.

Well, is it possible to search through all of the datastore?

Edit: Also I’ve tried making my own script on counting up my item but it didn’t turn out well…

In case you didn’t find this yourself yet, you can use DataStore:ListKeysAsync().


Best regards,
Pinker