I'm trying to do data saving for my game. Can anyone help?
game.Players.PlayerRemoving:Connect(function(player)
local Worked, Errorey = pcall(function()
local data = game:GetService("DataStoreService"):GetDataStore("Data")
data:SetAsync(player.UserId, game.ReplicatedStorage.Cash.Value)
data:SetAsync(player.UserId, game.ReplicatedStorage.Rebirth.Value)
data:SetAsync(player.UserId, game.ReplicatedStorage.X5.Value)
data:SetAsync(player.UserId, game.ReplicatedStorage.X2.Value)
end)
if Worked then
print("Okay,i saved data store. Fuw-w-w!")
else
warn(Errorey)
end
end)
( I'm bad at programming lol )

2 comments
you have the players value in ReplicatedStorage?
I don't know English well (I'm Russian), so can you explain what exactly?