Help with making a System that tracks how many of a item exist

I need help with a system that tracks how many of a item exist inside my game. I`m wanting to make this so players trading will be able to see the true value of a item by seeing how many of it exist (then if possible they can see who owns this item and maybe how much of the item the guy has)

the issue is that Im not sure where to begin nor how to achive this kind of system I know it would envolve data stores but after that I`m not sure what eles.

and I know this kind of system is possible becuse in Pet Sim X if you enable Pet datastore in the settings you can see how much of a pet exists

screenshoteasy (48)
(sorry for being blurry I just found this one online)

when you hover over a pet it shows how much of it exists and some other info

I`ve tried to search this with diffrent keywords and stuff but I havent been able to find anything

any help is appriciated!

3 Likes

This isn’t possible with Roblox Datastores, because you have a limit for every key. I think it is done by using an external database

1 Like

oh that would make sence, Guess I need to learn how to do that lol thanks tho

I have thougth for a bit and I think I could actually use OrderedDataStore if it works or dosent I`ll reply again

An idea you can try is creating a new datastore and updating it whenever an item is bought.

For example, let’s say your game has 500 orange helmets in circulation and then a player buys another one, you would add a 1 to the 500 in the datastore, totalling 501. Then you can just retrieve the datastore to view how many are in your game.

The problem with this is, if a player buys 100 it will cause severe throttling (data not being saved because it’s being limited). A way around this is to only update every 10 minutes. So let’s say a player buys another orange helmet, that purchase will get recorded in a table. After 10 minutes, your script will loop through the table and add all purchases to the datastore.

Make sure to also force save when the game is being shutdown.

2 Likes

Oh I never thought of doing it that way that`s super smart

You could avoid datastore and do something like this every time you open the GUI thing.

for i,v in ipairs(inventory:GetChildren()) do
    if v.Name == "LegendarySwordOfDoom" then
        v.Amount.Value = v.Amount.Value + 1
    end
end

Not sure how efficient it would be depending on the amount of items you have.

1 Like