game.Players.PlayerAdded:Connect(function(player)
local valueA = Instance.new("NumberValue",player)
valueA.Name = "money"
valueA.Value = 0
local data
local succuss, errormassage = pcall(function(player)
data = myDatastore:GetAsync(player.UserId.."-money")
if succuss then
print("succeassfuly loaded data")
else print ("ther was an error while retrieving your data")
warn(errormassage)
end
end)
local success, errormessage = pcall(function()
game.Players.PlayerRemoving:Connect(function(player)
myDatastore:SetAsync(player.Id.."-money",player.money.Value)
end)
if success then
print ("save succsses")
else print("there was an error while saving data")
warn(errormessage)
end
end)
end)
this is my code its to save your money when you leave the game and it dosent work if you could help that would be great the money val is in players.username.money.Value
