The datastore won't save the money I get from the code.
Here is the script for the datastore:
local dsService = game:GetService("DataStoreService")
local ds = dsService:GetDataStore("MoneyStats") -- Change this with a random data name!
game.Players.PlayerAdded:Connect(function(plr)
local folder = Instance.new("Folder", plr)
folder.Name = "leaderstats"
local currency = Instance.new("IntValue", folder)
currency.Name = "Money" -- Currency name.
currency.Value = ds:GetAsync(plr.UserId) or 0
currency.Changed:Connect(function()
ds:SetAsync(plr.UserId, currency.Value)
end)
end)
game.Players.PlayerRemoving:Connect(function(plr)
ds:SetAsync(plr.UserId, plr.leaderstats.Money.Value) -- Replace 'Money' with your currency name!
end)
I hope you could help me out.
Thank you!

1 comment
I do apologize that my question was not clear, I mean by the word "code" is codes that you can find and give you money, for example like RoCitizens.