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

2 comments
Don't use a RemoteFunction
What am i supposed to use then?