function dataSave(player,toUpdate)
local playerid = "Player" .. player.UserId
local success, err = pcall(function()
mystore:SetAsync(playerid,toUpdate)
end)
if success then
print("data saved!" .. success .. toUpdate)
else
print(toUpdate)
end
end
and this is the local script
local player = game:GetService("Players").LocalPlayer
local folder = player:WaitForChild("PlayerDataFolder")
local gameslot = folder.CurrentGame.Value
wait(3)
local toUpdate = {}
function updateDataStore()
game.ReplicatedStorage.DataSave:FireServer(player,toUpdate)
task.wait()
end
if folder.HasPlayed.Changed then
print("value changed!")
toUpdate.HasPlayed = folder.HasPlayed.Value
end
I just tried printing the toUpdate after a value change is supposed to be added to it and it’s nil. I’m guessing that’s the issue but I don’t know why it’s nil