Stringvalue Datastore Saving Issue

I want to be able to do the following in the diagram.

I’m trying to use datastores but whenever I try to retrieve the values it says nil.
Error: Unable to assign property Value. string expected, got nil

Script 1:

local datastore = game:GetService("DataStoreService"):GetDataStore("DataStore")
local Players = game.Players

local WallTexts = Instance.new("Folder")
WallTexts.Name = "WallTexts"
WallTexts.Parent = game.ReplicatedStorage

local Wall5 = Instance.new("StringValue") 
Wall5.Name = "Wall5"               
Wall5.Parent = WallTexts

local Wall10 = Instance.new("StringValue")
Wall10.Name = "Wall10"                 
Wall10.Parent = WallTexts

local key = "WallValues"

while wait(30) do
	local storedValues = datastore:GetAsync(key)
	if storedValues then
		print(Wall5.Value .. " is wall5's value")
		print(storedValues[1])
		Wall5.Value = storedValues[1] -- this is where it says error
		Wall10.Value = storedValues[2]
	end
end

Script 2:

local datastore = game:GetService("DataStoreService"):GetDataStore("DataStore")

repeat
	wait()
until game.ReplicatedStorage.WallTexts.Wall5

local WallTexts = game.ReplicatedStorage.WallTexts
local Wall5 = game.ReplicatedStorage.WallTexts.Wall5
local Wall10 = game.ReplicatedStorage.WallTexts.Wall10

local key = "WallValues"

Wall5.Changed:Connect(function(Change)
	datastore:SetAsync(key, Wall5.Value)
end)
Wall10.Changed:Connect(function(Change)
	datastore:SetAsync(key, Wall10.Value)
end)

I test this by editing the string value in server mode (Roblox studio) and I think it’s not saving properly.

1 Like

Or you’re trying to receive the Data wrong when using :GetAsync()

How would I receive it right? It worked on other projects this way for like simulators with coins and gems (everything in a single script).