Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How would I save the contents of something in a datastore?

Asked by 9 years ago

Let's say I wanted to save everything inside, say, ReplicatedStorage in a datastore.

Everything inside it would save and get loaded every time a player joined the place.

I need to figure out how it would save everything inside it, not specific objects inside of it.

If anybody is willing to assist me, that would be great.

The reason why I want this is because I am working on a data center and even if a player isn't online, I want their data to be accessible (hence writing all of the contents of ReplicatedStorage, the service where I am storing all userdata, to a datastore)

1 answer

Log in to vote
1
Answered by 9 years ago

You cannot store instances in datastores, but you can store tables of strings or number values to explain specific storage. Ex.:

local coins = 25
local favfood = "Doritos"
local datastore = game:GetService("DataStoreService"):GetDataStore("Stuff")
datastore:SetAsync(player.userId,{coins,favfood})
local async = datastore:GetAsync(player.userId)
print(async[1],async[2]) --prints(25,"Doritos")

You would have to create the instances manually using:

Instance.new("IntValue") --IntValue is an example
Ad

Answer this question