I'll make this short, so I am trying to make a currency save system, but it won't work. So If I change "lvl" to 5, next time when I join the game it'll say "0", that means that I have no currency, obviously, no output errors as far as I can see.
local players = game:GetService("Players")
local datastore = game:GetService("DataStoreService")
local ds1 = datastore:GetDataStore("CashValueSaver")
players.PlayerAdded:connect(function(player)
local folder = Instance.new("Folder")
folder.Name = "leaderstats"
folder.Parent = player
local currency1 = Instance.new("IntValue")
currency1.Name = "lvl"
currency1.Parent = player.leaderstats
currency1.Value = ds1:GetAsync(player.UserId) or 0
ds1:SetAsync(player.UserId, currency1.Value)
currency1.Changed:connect(function()
ds1:SetAsync(player.UserId, currency1.Value)
end)
end)
Thanks!

1 comment
Why would you save the data when currency1's value is changed? It would result in a lot of " DataStore request was added to queue" warnings.