Hello, I have a datastore script that is not working.
game.Players.PlayerAdded:Connect(function(plr)
wait()
local plrID = "id_"..plr.UserId
local Save1 = plr.Leaderstats.Cash
local GetSaved = DataStore:GetAsync(plrID)
if GetSaved then
Save1.Value = GetSaved[1]
else
local NumberForSaving = {Save1.Value}
DataStore:GetAsync(plrID, NumberForSaving)
end
end)
game.Players.PlayerRemoving:Connect(function(plr)
DataStore:GetAsync("id_"..plr.UserId, {plr.Leaderstats.Cash.Value})
end)```
The error states "Unable to cast Value to Object", which is put at line 12.