Hello,
I'm trying to learn DataStores and I'm unsure why this isn't working in Studio.
I've made sure the serverscript is in the serverscriptstorage and HTTP requests are on and also the allow studio API option.
-- Services
local DataStoreService = game:GetService("DataStoreService"):GetDataStore("SaveData")
-- DataStore
game.Players.PlayerAdded:connect(function(plr)
wait()
local GetSaved = DataStoreService:GetAsync("id_"..plr.userId)
if GetSaved then
plr.leaderstats.Cash.Value = GetSaved[1]
else
local NumberForSaving = {plr.leaderstats.Cash.Value}
DataStoreService:GetAsync("id_"..plr.userId, NumberForSaving)
end
end)
game.Players.PlayerRemoving:connect(function(plr)
DataStoreService:SetAsync("id"..plr.userId, {plr.leaderstats.Cash.Value})
end)
Thanks in advance for any help and feel free to set me a challenge to expand upon my knowledge of datastores.

1 comment
Sorry, I meant I have it in the serverscriptservice not storage.