Datastoring Questions!

Lets say I create a datastore and I call it PlayerExperience

local DataStoreService = game:GetService("DataStoreService")
local experienceStore = DataStoreService:GetDataStore("PlayerExperience")

Now, If I were to delete the whole script and create a new script and name the datastore “PlayerExperience”, would the data from the old script (before I deleted it) still save over to this new script?

Yes! Datastores are based on the game, not the script. You can access the datastore from any server script even multiple.

2 Likes

Oh! So as long as I have the name, I do not need to be afraid of losing data?

Once you play the game, which will run the script, the datastore “PlayerExperience” is created (if it doesn’t already exist). Then it doesnt matter if you delete that script or not, the datastore “PlayerExperience” and all the data in it will be accessible. BUT, this doesn’t mean you dont need to worry about dataloss. You should look at other topics that go more in-depth about preventing dataloss. If you search up “Datastore2” in the dev forums you can find a module someone made to prevent any dataloss and learn from that.

1 Like

Alright. Thank you for clarifying!

If you’re afraid of losing data (which might happen), I recommend using DataStore2.

In general, DataStore2 is one of the best (if not the best) method to prevent data loss.