Here are the 2 pieces of code:
local dsservice = game:GetService("DataStoreService"):GetDataStore("atcunleashed898") game.Players.PlayerAdded:Connect(function(plr) local uniquekey = "id-"..plr.UserId local money = game.ReplicatedStorage:WaitForChild("getmoney"):InvokeClient(plr) local getsaved = dsservice:GetAsync(uniquekey) print(money) local numbersforsaving = {money} dsservice:SetAsync(uniquekey,money,numbersforsaving) end) game.Players.PlayerRemoving:Connect(function(plr) local moneyvalue = game.ReplicatedStorage.getmoney:InvokeClient(plr) print(moneyvalue) local uniquekey = "id-"..plr.UserId local savetable = {moneyvalue} dsservice:SetAsync(uniquekey,moneyvalue,savetable) end)
function getMoney() script.Parent:WaitForChild("backdrop"):WaitForChild("money") return script.Parent.backdrop.money.Value end game.ReplicatedStorage.getmoney.OnClientInvoke = getMoney
Make sure the 2nd script is in a localscript. Also, SetAsync only takes 2 arguments (the unique key and the value stored) and you have provided 3. Also, I don't think the server to client communication is needed unless the value is under PlayerGui. Also, you are never setting the value of the money from the DataStore in your script.