Hello, so pretty, the datastores need to save a bunch of values.
In replicated storage, there are a few values that need to be saved for the next session, but these values are only set on the client side as these values only affect a players experience (render distance functionality, etc).
So, whenever the player clicks the “Save” button, it sends a table containing all of the values to the RemoteEvent to a server script and then it successfully saves everything.
But the problem is when you actually load into the game, so when you load into the game, a server script detects that you have joined the game and collects all of the data. And then it sends all of that data through the RemoteEvent again to a local script and sets everything in Replicated Storage. The thing is, it keeps saying that it is nil and I’m not exactly so sure why.
When you join the game, it loads
local passed, failed = pcall(function()
local data
data = SavingSettings:GetAsync(Player.UserId.."-Settings")
if data ~= nil then
game.ReplicatedStorage.SavingData:FireClient(Player, data)
end
end)
end)
If a player has pressed the save button
game.ReplicatedStorage.SavingData.OnServerEvent:Connect(function(Player, data)
local passed, failed = pcall(function()
SavingSettings:SetAsync(Player.UserId.."-Settings", data)
print(data)
end)
if passed then
print("saved")
end
end)
If a player has joined the game and it loads to lead their data (this is where the problem occurs)
game.ReplicatedStorage.SavingData.OnClientEvent:Connect(function(Player, Data)
for order, values in pairs(game.ReplicatedStorage:GetDescendants()) do
for dataorder, datavalue in pairs(Data) do
if dataorder == order then
values.Value = datavalue.Value
end
end
end
end)
Help would be greatly appreciated, thanks