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

DataStore involving a StringValue in ServerScriptService?

Asked by
Nidoxs 190
6 years ago

I have a String in a script in ServerScriptService, and it is changeable by voice, but I want the value of that string to save at the closing of a server and retrieve that saved value when the game reopens and return it into the string.

The StringValue isn't in a script, it's an object, how do I save the value of that string to a DataStore via a save script then when the game reopens, retrieve that saved string and set the value of the String to what has been retrieved?

--Nidoxs

local DataStoreService = game:GetService("DataStoreService")
local DStore = DataStoreService:GetDataStore("KLSaveArchive")

local HouseName = game.ServerScriptService.Systems.BannerSystem.HouseName
HouseName.Value = DStore:GetAsync("SavedHouse")

game.Close:connect(function()
    DStore:SetASync("SavedHouse", HouseName.Value)
end)

Answer this question