I have looked through my code and I think somewhere I have made it inefficient and caused data to be saved too quickly.
Right now I’m not using tables for the datastore, but I didn’t think that it would make a difference when there are 8 values being saved. Due to the datastore throttling the game has started to lag out every server and causing the game to be unplayable.
The datastore is for an egg hunt where you click on an egg when you find it but there are only 8 eggs. Perhaps to stop this from happening once the player has collected the egg I should destroy the click detector?
If there are only 8 eggs then somehow people are spamming that click detector. If you do not remove the click detector after they pickup the egg then they are most likely spamming it. Remove it after they pick it up and you should be set.
Get a local script, and go to the click detector and delete it.
Make sure the script doesn’t run into errors that is managing that click detector that is being deleted.
If it does, make sure to get the egg and do .Changed event, and see if the click detector == nil. if it is nil then yeah, no errors.
Actually another question is this a type of thing where once you pick up a egg nobody else can? Or is everyone allowed to pick up the eggs on the client side?
If im hearing you right each client is allowed to pick up each egg. In that case I would replicate the eggs to each client and then locally destroy each one when they pick it up. For more security I think it would be good if you sent that data to the server to actually validate that the person is not picking up eggs that should have been already picked up.
This can be easily done with a table and checking against that table. How you set this up depends on what type of game you are making and how the eggs actually work.
Don’t save data in intervals. It’s bad practice. What you want to do is implement a save for when the player leaves and when the server closes. Because Roblox utilizes a client-server network, regardless of if the player crashes, the server will always save the data. It is rare that the server should fail to do so, but even then, it’s an unfixable problem on your end.
If you want to save each player’s egg collection, use a server array for this storage.
Its not that its 8 values its that someone is spamming a click detector causing it to save every .1 of a second. You should make sure they can’t click anymore after they pickup a egg and this problem will go away.