Resetting datastores?

Good Day!

Let’s get right to it. I am trying to make a daily objectives feature to my game,


!!!
and I need to figure out how to change the data of all players that have used the datastore without them in the game. For instance a 3 players have 30 objective/task values in a datastore each(and each value has a different number based on completion), and precisely at 8:00 PM all of that data is reset to zero. I already have the daily script part, from this tutorial How to Make Server-Synced Daily Shops I just need the datastore part…
So is it possible to even do that? Could you tell me how to reset data that way?

2 Likes

you could set the data to nil and it should be gone.

You could just rename the datastore, resetting all of the data.

1 Like

But how would I get each players’ data?

I’d do this when the player joins.

1 Like

that’s true. i didn’t really think of that. i guess the best way is to use crxtix’s solution.

You can store a time value in the datastore, and whenever a player joins after the data gets wiped, you check that value to see if it’s up-to-date. If it’s not, then reset the data.

1 Like

this is exactly what I do, I think this solution is great

though it won’t be the solution for a http datastore

This works, although if a Datastore’s name is too large, it can error. It becomes an issue later on which can be a giant problem since you may also accidentally wipe progress people have made after a reset, depending on how old a server is.

Simply reset the datastore name, once reset everything will be gone.

The datastore name is like a key to access that variable, so changing It to a new variable will give a whole new set!

1 Like

Could this be a problem for me? What can I do to fix it?

What’s the max character limit?

There is no character limit its how you hold the values.
Also I don’t seem to know why you need a large name, something as simple as “Test551A” would work.

1 Like

Also which is a better idea,
@zCrxtix’s idea

or

@zQ86’s idea

What should I do?
  • crxtix
  • Zion

0 voters

Just change the datastore name, I posted on this section a few hours ago, it’s the easiest and the best option.
(to reset the datastore)

2 Likes

I believe there is a limit of 50 characters. Data Stores | Roblox Creator Documentation

1 Like

I have one question though, lets say I had a datastore with the random name of “robloxIsGreat”, then the next day it was “greatIsRoblox”, and then the next day it was “robloxIsGreat” again, would day 3’s data start off with day 1’s data?

Each time you change the name, all of the players’ data gets wiped.

1 Like

Hey, I have an idea how to store unique daily datastore’s names!

I have used similiar method to generate UUIDs.

local dateTable = os.date("*t")
local dataStoreName = "DS"..dateTable.yday..dateTable.year

-->> example of dataStoreName = DS2212021
-->> the benefits of this are  - low amount of characters,yday is once per year (obviously) + year is another unique aspect of this method
1 Like

Day 1: Data name is called "FirstDataSet"
Day 2: Data name is called "SecondDataSet"
Day 3: I set the name back to "FirstDataSet". Now the data from day 1 has returned. Renaming it basically just reads from a different collection of saved data. If I save something in "DataSave1" and return to it later, it will read the data that was stored there from before.


TLDR: It doesn’t get reset and will be there still even if you come back to it later. Changing the name to something different will indeed appear like the data has been wiped to others, but behind the scenes all you did was change what datastore you are reading from.

2 Likes

ok thanks, I will make sure that it doesn’t duplicate names!

I just thought of something though, what happens if there are two servers open while it changes the name, won’t there be two different names? Or will one of them overwrite the other, what should I do about that?