I just started working on datastores as I wanted to learn. I wrote up a code, and enabled API services. There are no errors in output, but when I change my values, they don't save can anyone help?
local DSService = game:GetService('DataStoreService'):GetDataStore('DataStore') game.Players.PlayerAdded:connect(function(plr) local uniquekey = 'id-'..plr.userId local leaderstats = Instance.new('IntValue', plr) local savevalue = Instance.new('IntValue') leaderstats.Name = 'leaderstats' savevalue.Parent = leaderstats savevalue.Name = 'Cash' local GetSaved = DSService:GetAsync(uniquekey) if GetSaved then savevalue.Value = GetSaved[1] else local NumbersForSaving = {savevalue.Value} DSService:SetAsync(uniquekey, NumbersForSaving) end end) game.Players.PlayerRemoving:connect(function(plr) local uniquekey = 'id-'..plr.userId local Savetable = {plr.leaderstats.Cash.Value} DSService:SetAsync(uniquekey, Savetable) end)
Closed as Not Constructive by User#19524
This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.
Why was this question closed?