Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Can a datastore be accessed by any script once created?

I created a datastore on one of my scripts here:

script #1

local DataStoreService = game:GetService("DataStoreService")
local playerData = DataStoreService:GetDataStore("playerSaveSystem")

And in script #1 I'm already saving some data and having it get loaded in. But I decided to save data at other specific moments when the player achieves something ( trying to create multiple opportunites for data to save )

Could I do something like this:

script #2

local DataStoreService = game:GetService("DataStoreService")
local SaveStrength = DataStoreService:GetDataStore("playerSaveSystem")

This being done in another script, not in the one that the datastore was created in. I'm assuming when I perform :GetDataStore() and put the name of the datastore I created then I have access to it from any script?

And if I perform the same process of saving onto this one will it actually save or will it save to another datastore that's only accessible through this one?

Edit:

i probably could've made this much shorter without the code and explained in words, sorry for the extra information

1 answer

✓ Accepted answer

It will save to the same datastore. So, the answer to your question is yes (as long it is in the same game).

2 comments

0

Thanks.

0

np

This discussion is preserved as it was. New answers, comments, and votes are closed.