Hello! Today I tried to create a place where you put a note and it lasts forever, like in this game:
Leave a note
The problem is that I’ve used datastore whenever a player joins or leaves, and now the player only sees his notes. Is there another way to save each model?
ok so this is kinda hard. you use listallkeys then use a for loop to create data for each key. if the key exceeds write limit then use metadata aswell and if that exceeds then create a new key. but the problem is that it will eat up your request for datastores so gl with that.
I just had to change the datastore key and make it the same for all players
Wait dont do that. Your server will start to ping and all requests will be queued (And if alot kf server acees same key it will glitch. Instead make a script that saves data each day instead of each player queuing up.
I suggest just using a single datastore and calling it multiple times from different servers. You don’t have to worry about overusing a datastore as long as you have a cooldown for your note placing. I think there is a 6 second cooldown for writing on the same key.
Another thing you can do is instead of writing each note, cache the data of notes up to a certain amount, then write them all at the same time onto other servers.
Also make sure to use UpdateAsync instead of SetAsync.
Another thing I suggest is using httpservice to create a JSON string if you save everything in a table or list, which I am assuming you need, to save the positions and everything. Saving it as a string will take up less data and put less strain on a datastore. I think, I’m not sure about that but most people use json strings anyways.
As for updating notes, I would suggest in a server, maybe every 10 mins, you can use GetAsync on the datastore, then you can compare it with your original data, or last retrieved data, then add any new notes that were since changed or added.
So yeah. Good luck with what you are creating
Thank you, I made it like this: when a player places a note, the system saves the note immediately. Is it fine?
It should be fine, but note if a lot of people are saving notes it might cause the datastore to error and stop saving notes. It would probably be best to cache notes, depending on how many people are saving notes. If your game only has like 1 or 2 people, then saving each note immediately is fine. But if you have hundreds, maybe consider caching the data of say, 10 or 20 notes then saving it all at once