I'm trying to store the data of the leaderstats DataStoreService. I'm not getting any errors but it is also not working. my code:
local ds = game:GetService("DataStoreService"):GetDataStore("SaveData") game.Players.PlayerAdded:Connect(function(plr) wait() local plrkey = "id_"..plr.userId local save1 = plr.leaderstats.Coins
local GetSaved = ds:GetAsync(plrkey)
if GetSaved then
save1.Value = GetSaved[1]
else
local NumberOfSaving = {save1.Value}
ds:GetAsync(plrkey, NumberOfSaving)
end
end)
game.Players.PlayerRemoving:Connect(function(plr) ds:SetAsync("id_"..plr.userId, {plr.leaderstats.Cash.Value}) end)

2 comments
you havent pcalled, so i can already tell its gonna be buggy anyway. i suggest watching AlvinBlox's tutorial on datastores
I followed the tutorial but I'm getting another error now. 17:35:01.492 - leaderstats is not a valid member of Player