local DStoreService = game:GetService("DataStoreService") local CashStore = DStoreService:GetDataStore("Cash")
game.Players.PlayerAdded:Connect(function(plr)
local CashValue = plr:WaitForChild("leaderstats"):WaitForChild("Cash").Value
DStoreService:UpdateAsync("plr_"..plr.UserId, CashValue)
end)
game.Players.PlayerRemoving:Connect(function(plr) DStoreService:GetAsync("plr_"..plr.UserId) end)

1 comment
also UpdateAsync takes a function, while SetAsync just takes the value to put in the Datastore like they did here