local DSService = game:GetService('DataStoreService'):GetDataStore('Playerleaderstats')
game.Players.PlayerAdded:connect(function(plr)
plr:WaitForChild("Inventory")
plr:WaitForChild("leaderstats")
local uniquekey = 'id-'..plr.userId
local Store = {
plr.leaderstats.Money.Value,
plr.leaderstats.Crystals.Value
}
local GetSaved = DSService:GetAsync(uniquekey)
if GetSaved then
Store = GetSaved
else
local UpSave = {Store}
DSService:UpdateAsync(uniquekey, UpSave)
end
end)
game.Players.PlayerRemoving:connect(function(plr)
local uniquekey = 'id-'..plr.userId
local SaveStore = {
plr.leaderstats.Money.Value,
plr.leaderstats.Crystals.Value}
DSService:SetAsync(uniquekey, SaveStore)
end)
For some reason my leaderstats does not seem to save. No error output is given either.

4 comments
Turn on API services in game page
Api Services are already on.
Saving only upon leaving is a bad habit. Make sure you also save data during gameplay.
If I recall correctly, PlayerAdded doesn't trigger in-studio because the player joins before the script even runs.