I have a String Value in Lighting that I need to save every time its value is changed. But I have no idea how to save anything in Roblox. So basically, how would I save a value, and then load it up again when you come back? I tried reading the Wiki article on Data Store but I had a lot of trouble understanding it.
✓ ANSWER ACCEPTED
How do I save a value?
1 answer
✓ Accepted answer
Some stuff about DataStores: http://wiki.roblox.com/index.php?title=Data_store
Note that you have to enable the DataStore API for your game if you want to try out DataStores in Studio mode. I can't find the link for that because I don't see the check box when I try to configure my place. Maybe someone will post that in the comments.
How to use it in your situation:
dsservice = game:GetService("DataStoreService")
datastore = dsservice:GetDataStore("A string that I have to save in a DataStore") --Here you're either getting a datastore that already exists, or making a new one.
datastore:SetAsync("String", game.Lighting.StringValue.Value) --Saving the StringValue object's Value to the key, "String", in the DataStore that we're using a variable for.
In another script:
dsservice = game:GetService("DataStoreService")
datastore = dsservice:GetDataStore("A string that I have to save in a DataStore")
text = datastore:GetAsync("String") --Gets the value of the key called "String" in the datastore
print(text)
1 comment
0
Is the string that have to save in data store is the name of the value that saves?
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
DataStore is complicated, idek but leik gl