What do you want to achieve? Keep it simple and clear!
I created a random chance reward system, and I would like to save a unique serial number for each reward. (I.e. Player1 received a super rare item, and would like to see the serial number of the item they own.
What is the issue? Include screenshots / videos if possible!:
I can’t seem to figure out how I would achieve a system like this. A datastore can only save every so often or else it crashes. I can’t have it save every 10+ seconds due to the chance of multiple of the same serial number occurring, which is guaranteed if there are more than one player using the reward system.
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I tried using datastores, but they cannot save as much as I need them to.
I couldn’t find any information that may help me on the Developer Hub.
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!:
Think, Avatar shop Limited’s. Every item has their own unique serial number.
If you know how I may achieve this, please let me know.
I disagree with that statement, first because DS2 and PS uses the Roblox DataStoreService…
Both are great resources that uses DataStoreService in a efficient way. Its easier to use that instead of creating your own saving system, kinda plug and play, awesome for developers that dont want headaches about creating the system or for devs that doesnt know how to create one.
Anyone can use the DataStoreService and make it work in a efficient way no needing to use those resources.
Each time a new item is created and its serial number its created, store it into a table in a server script or a module, when a new item is created check if the new serial number is already in the table or not, if it does return and create a new serial.
Then each idk 5 minutes (or whatever time or event you desire), use that table to update the datastore with the new items and serials.
Hey, thanks for the help. I’ll try this out when I have the chance. But what if a player from one server is using the reward system and they just so happen to get the same thing a player got in another server, before the Datastore got a chance to update?
Are you worried about someone in another server getting the same randomly generated serial number for an item they got, or are you more worried about there being a limited amount of an item, and you want to make sure two people on different servers didn’t both get the limited item?
To avoid on the same server is easy as others have mentioned; just keep a running table going and check before assigning the serial. To avoid people from other servers, you could just get the id of the server instance and append that to your serial numbers since the instance id is always going to be different on another server.
game.JobId comes back as a string so you won’t technically have a “number” but probably wouldn’t matter for what you need it for. Also, it’s really long. Like 32 characters separated by some dashes.
Thinking back, I needed to use instance id’s for something and split my save into two. So each item in your case could have a “Serial 1” and “Serial 2” value where Serial 1 is the first half of the serial and Serial 2 is the second half. Pull them both and combine when needed to get the full value?
Well that could probably work. But I could potentially be dealing with tons of serial numbers, so I just want to make sure the data store can take it. Maybe I can have a key set for each item to avoid overloading the datastores. And make sure that only the rare items have a serial number.
Example: dataStore(Item_1,Serials), dataStore(Item_2,Serials)
Just do HttpService:GenerateGUID(false), this returns a random, unique string, like this for example: 9cd6cd97-b2e3-4337-93c1-16d1cecbc2ab (the false argument is so that there is no brackets on the start and end of the string)