My datastore is throttling (Using DataStore2)

My game is using DataStore2 to save data for the players whenever they click on an item in game.

The issue is that the datastore is throttling but I only have 10 - 20 people in the game at once.

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.

What type of game is this exactly are they picking up items every few seconds or constantly clicking on something?

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.

Would you have any idea on how I could destroy the click detector locally so that it doesn’t affect anyone else?

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?

Everyone can collect the same egg at the same times.

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.

Why don’t you save all 8 eggs in a table? This would only use one data store and request twice per player, on join and on leave.

1 Like

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.

I’ll do that now, I just didn’t expect that 8 values would cause the datastore to throttle.

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.

I’ll format the data into a table and make sure that the click detector is destroyed once clicked to make sure no one can spam the egg.